AtCoder Beginner Contest 085 A 模拟即可。 123456789101112131415161718#include <iostream>using namespace std;int main(){ string s; while(cin>>s){ int l=s.length(); for(int i=0;i<l;i++){ if(i==0) cout<<'2'; else if(i==1) cout<<'0'; else if(i==2) cout<<'1'; else if(i==3) cout<<'8'; else cout<<s[i]; } cout<<endl; } return 0;} B 直接用set计算。 12345678910111213141516171819#include <iostream>#include <set>using namespace std;int main(){ int n; set<int> s; while(cin>>n){ s.clear(); while(n--){ int x; cin>>x; s.insert(x); } int sum=s.size(); cout<<sum<<endl; } return 0;} C 直接3重暴力即可。 123456789101112131415161718192021222324252627282930313233343536373839#include <iostream>#include <set>using namespace std;int main(){ int n, Y; while (cin >> n >> Y) { Y /= 1000; if (n * 10 < Y || n > Y) { cout << -1 << " " << -1 << " " << -1 << endl; continue; } int flag = 0; for (int i = n; i >= 0; i--) { for (int j = n - i; j >= 0; j--) { for (int l = n - i - j; l >= 0; l--) { if ((i + j + l == n) && (i * 10 + j * 5 + l == Y)) { cout << i << " " << j << " " << l << endl; flag = 1; break; } } if (flag) break; } if (flag) break; } if (!flag) cout << -1 << " " << -1 << " " << -1 << endl; } return 0;} ## D 直接贪心即可。 123456789101112131415161718192021222324252627282930313233343536373839404142#include<iostream>#include<bits/stdc++.h>using namespace std;const int N=2e5+20;struct node{ int a; int x;//0砍 1飞}s[N];bool cmp(node x,node y){ return x.a>y.a;//手写cmp}int main(){ int h,n; cin>>n>>h; for(int i=1;i<=2*n;++i){ cin>>s[i].a; if(i&1){ s[i].x=0;//砍 } else { s[i].x=1;//飞 } } sort(s+1,s+1+2*n,cmp); int ans=0; for(int i=1;i<=2*n;++i){ if(h<=0){ break;//如果怪死了,退出 } if(s[i].x==0){ ans+=ceil(h*1.0/s[i].a);//如果砍,全部用砍 break; } else { h-=s[i].a;//飞只使用一次 ++ans; } } cout<<ans<<'\n';//输出 return 0;}