A. Majestic 10
题意:三个数均大于10则输出“triple-double”,如果两个数大于10则输出“double-double",如果一个大于10则输出“double”,如果没有数大于10则输出“zilch”
#include<stdio.h> int main(){ int n,a,b,c; scanf("%d",&n); while(n--){ scanf("%d %d %d",&a,&b,&c); int sum=0; printf("%d %d %d\n",a,b,c); if(a>=10) sum++; if(b>=10) sum++; if(c>=10) sum++; if(sum==0){ printf("zilch\n"); }else if(sum==1){ printf("double\n"); }else if(sum==2){ printf("double-double\n"); }else if(sum==3){ printf("triple-double\n"); } printf("\n"); } }
B.Phoneme Palindromes
题意:判断是否是回文字符串,给出的某些字母可以进行替换
1 #include <cstdio> 2 #include <iostream> 3 #include <algorithm> 4 #include <cmath> 5 #include <string> 6 #include <cstring> 7 #include <map> 8 using namespace std; 9 map <char,int> fin; 10 char q = ‘a‘; 11 int main(){ 12 int t; 13 scanf("%d",&t); 14 getchar(); 15 int intm = 1; 16 while(t--){ 17 for(int j = 0;j < 26;j++) 18 fin[q+j] = j; 19 int m; 20 scanf("%d",&m); 21 getchar(); 22 for(int j = 0;j < m;j++){ 23 char a,b; 24 cin>>a; 25 getchar(); 26 cin >> b; 27 getchar(); 28 fin[a] = fin[b]; 29 } 30 int n; 31 scanf("%d",&n); 32 getchar(); 33 string s[110]; 34 for(int j = 0;j < n;j++){ 35 cin >> s[j]; 36 getchar(); 37 } 38 printf("Test case #%d:\n",intm); 39 m++; 40 for(int j = 0; j < n;j++){ 41 int fn = 1; 42 int len = s[j].size(); 43 for(int k = 0;k < len / 2;k++){ 44 if(fin[s[j][k]] != fin[s[j][len-k-1]]){ 45 fn = 0; 46 break; 47 } 48 } 49 if(fn == 1) 50 cout << s[j] << " " << "YES" << endl; 51 else 52 cout << s[j] << " " << "NO" << endl; 53 } 54 cout << endl; 55 } 56 return 0; 57 }
C
题目:如果一行中或列中没有冰块则不可敲,否则可以敲击此冰块使得同行和同列的直接掉落
思路:直接进行遍历统计即可
1 #include<algorithm> 2 #include<cstring> 3 #include<cstdio> 4 #include<cmath> 5 #include<iostream> 6 #include<vector> 7 using namespace std; 8 int main(){ 9 int a[1000],dx[1000],dy[1000]; 10 int n,m,k,h,l,s; 11 scanf("%d",&n); 12 m=n; 13 while(n--){ 14 scanf("%d %d",&h,&s); 15 for(int i=0;i<s;i++){ 16 scanf("%d %d",&dx[i],&dy[i]); 17 } 18 int sum=0; 19 for(int i=1;i<s;i++){ 20 int flagx=0,flagy=0; 21 if(dx[i]>h){ 22 dx[i]=0; 23 dy[i]=0; 24 sum++; 25 } 26 if(dy[i]>h){ 27 dx[i]=0; 28 dy[i]=0; 29 sum++; 30 } 31 for(int j=0;j<i;j++){ 32 if(dx[j]==dx[i]) flagx++; 33 if(dy[j]==dy[i]) flagy++; 34 35 } 36 if(flagx>=1&&flagy>=1){ 37 dx[i]=0; 38 dy[i]=0; 39 sum++; 40 } 41 } 42 printf("Strategy #%d: %d\n",m-n,sum); 43 printf("\n"); 44 } 45 }
D
题意:女儿会循环播放一首歌曲,在女儿下车后,此人仍然会继续顺序循环播放,问此人可以听女儿喜欢的歌曲多长时间
思路:直接计算即可,女儿在车上的时间直接加起来,不在车上的算循环播放的时间里面包含的这首歌时长
1 #include<algorithm> 2 #include<cstring> 3 #include<cstdio> 4 #include<cmath> 5 #include<iostream> 6 #include<vector> 7 using namespace std; 8 int main(){ 9 int a[1000],dx[1000],dy[1000]; 10 int n,m,k,h,l,s; 11 scanf("%d",&n); 12 m=n; 13 while(n--){ 14 scanf("%d %d",&h,&s); 15 for(int i=0;i<s;i++){ 16 scanf("%d %d",&dx[i],&dy[i]); 17 } 18 int sum=0; 19 for(int i=1;i<s;i++){ 20 int flagx=0,flagy=0; 21 if(dx[i]>h){ 22 dx[i]=0; 23 dy[i]=0; 24 sum++; 25 } 26 if(dy[i]>h){ 27 dx[i]=0; 28 dy[i]=0; 29 sum++; 30 } 31 for(int j=0;j<i;j++){ 32 if(dx[j]==dx[i]) flagx++; 33 if(dy[j]==dy[i]) flagy++; 34 35 } 36 if(flagx>=1&&flagy>=1){ 37 dx[i]=0; 38 dy[i]=0; 39 sum++; 40 } 41 } 42 printf("Strategy #%d: %d\n",m-n,sum); 43 printf("\n"); 44 } 45 }
03.28,周六,12:00-17:00,ICPC训练联盟周赛,选用试题:UCF Local Programming Contest 2016正式赛。
原文:https://www.cnblogs.com/bonel/p/12621407.html