2020.3.28 UCF Local Programming Contest 2016补题与解题报告
Posted ccccrack
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2020.3.28 UCF Local Programming Contest 2016补题与解题报告相关的知识,希望对你有一定的参考价值。
A.Majestic 10
大致题意就是指看有几个大于等于10,直接按照题意输出就行,签到题
#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 ",a,b,c); if(a>=10) sum++; if(b>=10) sum++; if(c>=10) sum++; if(sum==0){ printf("zilch "); }else if(sum==1){ printf("double "); }else if(sum==2){ printf("double-double "); }else if(sum==3){ printf("triple-double "); } printf(" "); } }
B. Phoneme Palindromes
代码:
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <map> using namespace std; map <char,int> ma; char q = ‘a‘; int main(){ int t; cin >> t; getchar(); int intm = 1; while(t--){ for(int j = 0;j < 26;j++) ma[q+j] = j; int m; cin >> m; getchar(); for(int j = 0;j < m;j++){ char a,b; cin >> a; getchar(); cin >> b; getchar(); ma[a] = ma[b]; } int n; cin >> n; getchar(); string s[110]; for(int j = 0;j < n;j++){ cin >> s[j]; getchar(); } printf("Test case #%d: ",intm); intm++; for(int j = 0; j < n;j++){ int fn = 1; int len = s[j].size(); for(int k = 0;k < len / 2;k++){ if(ma[s[j][k]] != ma[s[j][len-k-1]]){ fn = 0; break; } } if(fn == 1) cout << s[j] << " " << "YES" << endl; else cout << s[j] << " " << "NO" << endl; } cout << endl; } return 0; }
意思就是一个给定大小的棋盘,棋盘上面的格子都是可以拿下来的,之后给出移动策略,就是敲方块的顺序,问哪些操作是无效的
代码:
#include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<iostream> #include<vector> using namespace std; int main(){ int a[1000],dx[1000],dy[1000]; int n,m,k,h,l,s; scanf("%d",&n); m=n; while(n--){ scanf("%d %d",&h,&s); for(int i=0;i<s;i++){ scanf("%d %d",&dx[i],&dy[i]); } int sum=0; for(int i=1;i<s;i++){ int flagx=0,flagy=0; if(dx[i]>h){ dx[i]=0; dy[i]=0; sum++; } if(dy[i]>h){ dx[i]=0; dy[i]=0; sum++; } for(int j=0;j<i;j++){ if(dx[j]==dx[i]) flagx++; if(dy[j]==dy[i]) flagy++; } if(flagx>=1&&flagy>=1){ dx[i]=0; dy[i]=0; sum++; } } printf("Strategy #%d: %d ",m-n,sum); printf(" "); } }
D. Wildest Dreams
代码:
#include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<iostream> #include<vector> using namespace std; int ts[1000],ds[1000]; int main(){ int n,t,k,d,m; scanf("%d",&n); m=n; while(n--){ int summ=0; printf("CD #%d: ",m-n); scanf("%d %d",&t,&k); for(int i=0;i<t;i++){ scanf("%d",&ts[i]); summ+=ts[i]; } scanf("%d",&d); while(d--){ int num,sum=0; scanf("%d",&num); for(int j=1;j<=num;j++){ scanf("%d",&ds[j]); if(j%2==1){ sum+=ds[j]; }else{ int item; if(ds[j-1]%ts[k-1]==0){ item=0; }else{ item=(ts[k-1]-ds[j-1]%ts[k-1]);//item属于没看完的 } if(ds[j]<=item){ sum+=ds[j]; }else{ sum+=(item+((ds[j]-item)/summ*ts[k-1]));//后一部分属于有几个整的cd } if((summ-ts[k-1])<(ds[j]-item)%summ){ sum+=((ds[j]-item)%summ-(summ-ts[k-1])); } } } printf("%d ",sum); } printf(" "); } }
以上是关于2020.3.28 UCF Local Programming Contest 2016补题与解题报告的主要内容,如果未能解决你的问题,请参考以下文章
UCF Local Programming Contest 2015
UCF Local Programming Contest Round 1A 训练联盟暑假场1 题解
UCF Local Programming Contest 2017(2020-04-06)
UCF Local Programming Contest 2012(Practice)补题