1001-1167(持续更新)
1001 A+B Format (20 分)#include1002 A+B for Polynomials (25 分)using namespace std; int main(){ int a,b; scanf("%d%d",&a,&b); int c = a+b; if(c<0){ cout << "-"; } c = abs(c); if(c < 1000){ cout << c % 1000 << endl; }else if(c<1000000){ cout << c/1000 << ","; printf("%03dn",c%1000); }else{ cout << c/1000000 << ","; printf("%03d,%03dn",c/1000%1000,c%1000); } return 0; }
#include1005 Spell It Right (20 分)using namespace std; double a[1005]; double b[1005]; double c[1005]; int main(){ int K; int emax = -1; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); scanf("%d",&K); for(int i=1;i<=K;i++){ int e; double coeff; scanf("%d%lf",&e,&coeff); emax = max(emax,e); a[e] = coeff; } scanf("%d",&K); for(int i=1;i<=K;i++){ int e; double coeff; scanf("%d%lf",&e,&coeff); emax = max(emax,e); b[e] = coeff; } for(int i=emax;i>=0;i--){ c[i] = b[i] + a[i]; } int cnt = 0; for(int i=emax;i>=0;i--){ if(c[i]!=0){ cnt++; } } cout << cnt; for(int i=emax;i>=0;i--){ if(c[i]!=0){ printf(" "); printf("%d %.1lf",i,c[i]); } } return 0; }
#includeusing namespace std; int main(){ string s; cin >> s; int total = 0; for(int i=0;i 1006 Sign In and Sign Out (25 分) #include1009 Product of Polynomials (25 分)using namespace std; int Great(int h1,int m1,int s1,int h2,int m2,int s2){ if(h1!=h2){ return h1>h2; }else if(m1!=m2){ return m1>m2; }else if(s1!=s2){ return s1>s2; } } int main(){ int M; cin >> M; int ans_h = 24, ans_m = 0, ans_s = 0; int end_h = 0, end_m = 0, end_s = 0; string s1,s2; for(int i=0;i > s; int s_h,s_m,s_s; int e_h,e_m,e_s; scanf("%d:%d:%d",&s_h,&s_m,&s_s); scanf("%d:%d:%d",&e_h,&e_m,&e_s); if(Great(ans_h,ans_m,ans_s,s_h,s_m,s_s)){ ans_h = s_h; ans_m = s_m; ans_s = s_s; s1 = s; } if(Great(e_h,e_m,e_s,end_h,end_m,end_s)){ end_h = e_h; end_m = e_m; end_s = e_s; s2 = s; } } cout << s1 << " " << s2 << endl; return 0; } #include1011 World Cup Betting (20 分)using namespace std; double a[2005]; double b[2005]; double c[2005]; int main(){ int K; int emax = -1; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); scanf("%d",&K); for(int i=1;i<=K;i++){ int e; double coeff; scanf("%d%lf",&e,&coeff); emax = max(emax,e); a[e] = coeff; } scanf("%d",&K); for(int i=1;i<=K;i++){ int e; double coeff; scanf("%d%lf",&e,&coeff); emax = max(emax,e); b[e] = coeff; } for(int i=emax;i>=0;i--){ for(int j=emax;j>=0;j--){ if(a[i]!=0.0 && b[j]!=0.0){ c[i+j] += a[i] * b[j]; } } } int cnt = 0; for(int i=2*emax;i>=0;i--){ if(c[i]!=0.0){ cnt++; } } cout << cnt; for(int i=2*emax;i>=0;i--){ if(c[i]!=0.0){ printf(" "); printf("%d %.1lf",i,c[i]); } } return 0; } #include1019 General Palindromic Number (20 分)using namespace std; double a[5][5]; string s = " WTL"; int b[5]; int main(){ for(int i=1;i<=3;i++){ for(int j=1;j<=3;j++){ scanf("%lf",&a[i][j]); } } double res = 1.0; for(int i=1;i<=3;i++){ double minn = -1.0; int site; for(int j=1;j<=3;j++){ if(a[i][j]>minn){ minn = a[i][j]; site = j; } } b[i] = site; res *= minn; } res = (res*0.65-1)*2; for(int i=1;i<=3;i++){ printf("%c ",s[b[i]]); } printf("%.2lfn",res); return 0; } #include1027 Colors in Mars (20 分)using namespace std; int a[105]; int main(){ int n,b; cin >> n >> b; int cnt = 0; while(n){ a[cnt++] = n%b; n/=b; } bool flag = true; for(int i=0;i =0;i--){ if(i!=0){ cout << a[i] << " "; }else{ cout << a[i] << endl; } } return 0; } #include1031 Hello World for U (20 分)using namespace std; string s = "0123456789ABC"; int main(){ cout << "#"; for(int i=1;i<=3;i++){ int t; cin >> t; int a,b; a = t/13; b = t%13; cout << s[a] << s[b]; } return 0; } #includeusing namespace std; int main(){ string s; cin >> s; int N = s.size(); int n1,n3; n1 = n3 = (N+2)/3; int n2 = N+2 - n1 - n3; for(int i=0;i 1035 Password (20 分) #includeusing namespace std; struct team{ string name; string p; }; team t[10005]; int main(){ int M; scanf("%d",&M); int cnt = 0; for(int i=0;i > name >> password; bool f = false; for(int j=0;j 1036 Boys vs Girls (25 分) #include1042 Shuffling Machine (20 分)using namespace std; int main(){ int M; cin >> M; string m_name; string f_name; string m_course; string f_course; int m_score = 101; int f_score = -1; for(int i=0;i > s; string sex; cin >> sex; string course; cin >> course; int score; cin >> score; if(sex == "M"){ if(score<=m_score){ m_score = score; m_name = s; m_course = course; } }else{ if(score >= f_score){ f_score = score; f_name = s; f_course = course; } } } if(m_score == 101 && f_score == -1){ cout << "Absent" << endl << "Absent" << endl << "NA" ; }else if(f_score == -1){ cout << "Absent" << endl << m_name << " " << m_course << endl << "NA"; }else if(m_score == 101){ cout << f_name << " " << f_course << endl << "Absent" << endl << "NA" ; }else{ cout << f_name << " " << f_course << endl << m_name << " " << m_course << endl << f_score-m_score; } return 0; } #include1046 Shortest Distance (20 分)using namespace std; int a[105]; int b[105]; int c[105]; string s = "SHCDJ"; int main(){ int K; cin >> K; for(int i=1;i<=54;i++){ a[i] = i; } for(int i=1;i<=54;i++){ cin >> b[i]; } for(int i=1;i<=K;i++){ for(int j=1;j<=54;j++){ c[b[j]] = a[j]; } for(int j=1;j<=54;j++){ a[j] = c[j]; } } for(int i=1;i<=54;i++){ cout << s[(a[i]-1)/13]; cout << (a[i]-1) % 13 + 1; if(i!=54){ cout << " "; }else{ cout << endl; } } return 0; } #include1058 A+B in Hogwarts (20 分)using namespace std; const int maxn = 1e5+5; int a[maxn]; int sum[maxn]; int main(){ int N; cin >> N; for(int i=1;i<=N;i++){ cin >> a[i]; sum[i] = sum[i-1] + a[i]; } int cnt = sum[N]; int M; cin >> M; for(int i=1;i<=M;i++){ int s1,s2; cin >> s1 >> s2; if(s1>s2){ swap(s1,s2); } int res; res = min(sum[s2-1]-sum[s1-1],cnt-(sum[s2-1]-sum[s1-1])); cout << res << endl; } return 0; } #include1061 Dating (20 分)using namespace std; string str1,str2; int a[3]; int b[3]; int c[3]; int main(){ cin >> str1 >> str2; int site1 = str1.find('.'); int site2 = str1.find('.',site1+1); for(int i=0;i =0;i--){ a[i] = a[i] + b[i]; if(i==2){ a[i] = a[i] + jw; jw = a[i]/29; a[i] = a[i] % 29; }else if(i==1){ a[i] = a[i] + jw; jw = a[i]/17; a[i] = a[i] % 17; }else{ a[i] += jw; } } cout << a[0] << "." << a[1] << "." << a[2] << endl; return 0; } #includeusing namespace std; string str[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; int isupper(char c){ if(c>='A' && c<='G'){ return 1; }else{ return 0; } } int isalpha(char c){ if(c>='A' && c<='Z'){ return 1; }else if(c>='a' && c<='z'){ return 1; }else{ return 0; } } int main(){ string s1,s2,s3,s4; char day,hour; int minute; cin >> s1 >> s2 >> s3 >> s4; int size1 = min(s1.size(),s2.size()); int size2 = min(s3.size(),s4.size()); int count = 0; for(int i=0;i ='0' && s1[i]<='9')||(s2[i]>='A' && s2[i]<='N')) && count!=0){ hour = s1[i]; break; } } for(int i=0;i 1062 Talent and Virtue (25 分) #includeusing namespace std; int N,L,H; typedef struct score{ int IDnum; int Dscore; int Cscore; }score; const int maxn = 1e5+5; score DC1[maxn]; score DC2[maxn]; score DC3[maxn]; score DC4[maxn]; bool cmp(score s1,score s2){ if(s1.Cscore+s1.Dscore>s2.Cscore+s2.Dscore){ return true; }else if(s1.Cscore+s1.Dscore == s2.Cscore+s2.Dscore){ if(s1.Dscore>s2.Dscore){ return true; }else if (s1.Dscore == s2.Dscore){ if(s1.IDnum > N >> L >> H; int first = 0,second =0,third =0,fourth =0; int nopass = 0; for(int i=0;i =H && c>=H){ DC1[first].IDnum = a; DC1[first].Dscore = b; DC1[first++].Cscore = c; }else if(b>=H && c =c){ DC3[third].IDnum = a; DC3[third].Dscore = b; DC3[third++].Cscore = c; }else{ DC4[fourth].IDnum = a; DC4[fourth].Dscore = b; DC4[fourth++].Cscore = c; } } cout << N-nopass << endl; sort(DC1,DC1+first,cmp); sort(DC2,DC2+second,cmp); sort(DC3,DC3+third,cmp); sort(DC4,DC4+fourth,cmp); for(int i=0;i 1065 A+B and C (64bit) (20 分) #include1073 Scientific Notation (20 分)using namespace std; int main(){ int T; cin >> T; long long a,b,c; for(int i=1;i<=T;i++){ scanf("%lld%lld%lld",&a,&b,&c); cout << "Case #" << i << ": "; long long res = a+b; if(a>0 && b>0 && res<0){ cout << "true" << endl; }else if(a>0 && b>0 && res==0){ cout << "true" << endl; }else if(a<0 && b<0 && res>0){ cout << "false" << endl; }else if(a<0 && b<0 && res==0){ cout << "false" << endl; }else if(res>c){ cout << "true" << endl; }else{ cout << "false" << endl; } } return 0; } #includeusing namespace std; int main(){ string str; cin >> str; int site = str.find('E'); string n = str.substr(1,site-1); string e = str.substr(site+1); int en = stoi(e); if(str[0] == '-'){ cout << "-"; } if(en>=0){ cout << str[1]; int j=2,cnt=0; for(j=2;j 1077 Kuchiguse (20 分) #include1082 Read Number in Chinese (25 分)using namespace std; string s[105]; int main(){ int N; cin >> N; getchar(); int minn = INT_MAX; for(int i=0;i =0;i--){ cout << s[0][i]; } cout << endl; }else{ cout << "nai" << endl; } return 0; } #includeusing namespace std; string out[] = {"","Shi","Bai","Qian","Wan","Yi"}; string digit[] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; int main(){ int n; cin >> n; if(n<0){ cout << "Fu "; } n = abs(n); if(n==0){ cout << "ling" << endl; return 0; } char str[15]; sprintf(str,"%d",n); int len = strlen(str); int left = 0; int right = len-1; while(left+4<=right){ right -= 4; } while(left 0){ cout << " " << digit[str[left]-'0']; }else{ cout << digit[str[left]-'0']; } if(right!=left){ cout << " " << out[right-left]; } } left++; } int k = (len-left)/4 + 3; if(left!=len){ cout << " " << out[k]; } right += 4; } return 0; }



