版本比较
【K-R1】五一赛•赛后题解
标题
增加 1 行删除 1 行
11【K-1】五一赛•赛后题解【K-R1】五一赛•赛后题解正文
增加 20 行删除 20 行
11 行未改动121314151616171819207 行未改动28293031323334353233343536373940414243444546474849505152383940414243444546474849505152535455555657585932 行未改动11 行未改动 cout<<a+b; return 0;}```## T2 [$\color{red}\text{【K-1】四则运算计算器}$](https://www.luogu.com.cn/problem/U647071?contestId=324578)## T2 [$\color{red}\text{【K-R1-T2】四则运算计算器}$](https://www.luogu.com.cn/problem/U647071?contestId=324578)根据题目要求进行计算和输出对应算式即可。```cpp#include <iostream>using namespace std;7 行未改动 if(c==4) cout<<a<<"/"<<b<<"="<<a/b; return 0;}```## T3 [$\color{red}\text{【K-1】罗马数字}$](https://www.luogu.com.cn/problem/U649172?contestId=324578)从表示最大数字的 $M$ 开始逐步向下推即可,每输出一个字母之后将题目给出的数字 $n$ 减去输出字母代表的数字。
**注意特判 $4$ 和 $9$ 这两个数字。**## T3 [$\color{red}\text{【K-R1-T3】罗马数字}$](https://www.luogu.com.cn/problem/U649172?contestId=324578)**注意特判 $4$ 和 $9$ 这两个数字即可。**```cpp#include <iostream>#include <string>using namespace std;int main(){ int n; cin>>n; if(n==4) {cout<<"IV";return 0;} if(n==9) {cout<<"IX";return 0;} while(n/1000) {cout<<"M";n-=1000;} while(n/500) {cout<<"D";n-=500;} while(n/100) {cout<<"C";n-=100;} while(n/50) {cout<<"L";n-=50;} while(n/10) {cout<<"X";n-=10;} while(n/5) {cout<<"V";n-=5;} while(n/1) {cout<<"I";n-=1;} return 0;int main(){ int n; cin>>n; int v[]={1000,900,500,400,100,90,50,40,10,9,5,4,1}; string r[]={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; string s; for(int i=0;i<13;i++){ while(n>=v[i]){ s+=r[i]; n-=v[i]; } if(n==0)break; } cout<<s<<endl; return 0;}```## T4 [$\color{orange}\text{【K-1】恩格尔系数}$](https://www.luogu.com.cn/problem/U678883?contestId=324578)## T4 [$\color{orange}\text{【K-R1-T4】恩格尔系数}$](https://www.luogu.com.cn/problem/U678883?contestId=324578)根据题目计算即可,下列给出的代码使用的是百分数比较。```cpp#include <iostream>using namespace std;32 行未改动