比赛链接:
https://www.luogu.com.cn/contest/324578#description
点击题目标题可以跳转到对应题目。
T1
十年OI一场空,不开 long long 见祖宗。
#include <iostream>
using namespace std;
int main(){
long long a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}T2
根据题目要求进行计算和输出对应算式即可。
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>c>>a>>b;
if(c==1) cout<<a<<"+"<<b<<"="<<a+b;
if(c==2) cout<<a<<"-"<<b<<"="<<a-b;
if(c==3) cout<<a<<"*"<<b<<"="<<a*b;
if(c==4) cout<<a<<"/"<<b<<"="<<a/b;
return 0;
}T3
从表示最大数字的 开始逐步向下推即可,每输出一个字母之后将题目给出的数字 减去输出字母代表的数字。
注意特判 和 这两个数字。
#include <iostream>
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;
}T4
根据题目计算即可,下列给出的代码使用的是百分数比较。
#include <iostream>
using namespace std;
int main()
{
float x,y;
cin>>x>>y;
int N=x/y*100;//乘以100后变成百分数形式比较
if(N>=60) cout<<"Poor";
else if(N>=50&&N<60) cout<<"Food and clothing";
else if(N>=40&&N<50) cout<<"Wealthy";
else if(N>=30&&N<40) cout<<"Relative rich";
else if(N>=20&&N<30) cout<<"Rich";
else cout<<"Extremely rich";
return 0;
}其他
出题灵感来源于生活。
艺术源于生活,生活比艺术更艺术