比赛链接:
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>
#include <string>
using namespace std;
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
根据题目计算即可,下列给出的代码使用的是百分数比较。
#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;
}其他
出题灵感来源于生活。
艺术源于生活,生活比艺术更艺术