补题*总结题 Gym 102263
C - Check The Text
题目链接.
题意:
给出几个单词,通过输入再复现这几个单词,判断是否复现成功
掌握知识:
- if(strcmp(t," Backspace ")用双引号
- scanf("%s",a[i]);不能输入空格
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; scanf("%d",&n); int i; char a[n+1][200001]; for(i=0; i<n; i++) { scanf("%s",a[i]); // printf("%s\n",a[i]); } int m; scanf("%d",&m); // printf("***%d %d***\n",m,n); char b[n+1][200001]; int j=0; int u=0; int flag=0; char t[20]; int ooo=0; for(i=0; i<m; i++) { scanf("%s",t); if(strlen(t)==1) { b[u][j]=t[0]; if(flag==1) { b[u][j]=b[u][j]-32; } j++; } else if(strcmp(t,"Backspace")==0) { if(j==0&&u==0) { } else if(j==0) { u--; j=ooo; } else { j--; } } else if(strcmp(t,"Space")==0) { ooo=j; b[u][j]='\0'; //b[i][j]=' '; j=0; u++; } else if(strcmp(t,"CapsLock")==0) { flag=(flag+1)%2; } } b[u][j]='\0'; int count=1; for(i=0; i<n; i++) { // printf("%s ",a[i]); // printf("%s \n",b[i]); if(strcmp(a[i],b[i])!=0) { count=0; break; } } if(count==1) { printf("Correct\n"); } else { printf("Incorrect\n"); } return 0; }
B - Road to Arabella(博弈论)
题目链接.
题意:
输入n,k。两个人轮流选一个数x(1<=x<=max(1,n-k))减去n,若到一个人的回合n=0那么那个人失败。Kilani先手。
思路:数学归纳
掌握知识:
1.做不出来题,可以数学归纳
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int t; scanf("%d",&t); int n,k; int flag; while(t--) { flag=1; scanf("%d %d",&n,&k); if(n-k== 1||n-k==0) { if(n%2==0) flag=0; } if(flag) printf("Kilani\n"); else{printf("Ayoub\n");} } return 0; }
本文作者:kingwzun
本文链接:https://www.cnblogs.com/kingwz/p/15224760.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步