补题*总结题 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;
}

浙公网安备 33010602011771号