A.Pokemon Master
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
int n,m;
int main()
{
int t,i,j,a;
scanf("%d",&t);
while(t--)
{
int sum1=0,sum2=0;
scanf("%d%d",&n,&m);
for(i=0; i<n; i++)
{
scanf("%d",&a);
sum1+=a;
}
for(i=0; i<m; i++)
{
scanf("%d",&a);
sum2+=a;
}
if(sum1>sum2)
printf("Calem\n");
else if(sum1<sum2)
printf("Serena\n");
else printf("Draw\n");
}
return 0;
}
G.Ternary Calculation
模拟。。。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
char str1[10],str2[10];
int main()
{
int t,i,j,d,in,a,b,c;
scanf("%d",&t);
while(t--)
{
scanf("%d%s%d%s%d",&a,str1,&b,str2,&c);
if((str2[0]=='*'||str2[0]=='/'||str2[0]=='%')&&(str1[0]=='+'||str1[0]=='-'))
{
d=0;
in=0;
if(str2[0]=='*')
d=b*c;
else if(str2[0]=='/')
d=b/c;
else if(str2[0]=='%')
d=b%c;
if(str1[0]=='+')
in=a+d;
else if(str1[0]=='-')
in=a-d;
printf("%d\n",in);
}
else
{
d=0;
if(str1[0]=='+')
d=a+b;
else if(str1[0]=='-')
d=a-b;
else if(str1[0]=='*')
d=a*b;
else if(str1[0]=='/')
d=a/b;
else if(str1[0]=='%')
d=a%b;
if(str2[0]=='+')
d+=c;
else if(str2[0]=='-')
d-=c;
else if(str2[0]=='%')
d%=c;
else if(str2[0]=='*')
d*=c;
else if(str2[0]=='/')
d/=c;
printf("%d\n",d);
}
}
return 0;
}
J.What day is that day?
找规律。。。赛上wz一直在找,出了好多错,结果比赛结束也没A。赛后不甘心,自己找了一下,循环节是294.。。。
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int n[300];
int main()
{
int sum=0,i,j,num;
for(i=1; i<=294; i++)
{
num=1;
for(j=1; j<=i; j++)
num=(num*(i%7))%7;
sum+=num%7;
n[i]=sum%7;
}
n[0]=n[294];
int t,m;
scanf("%d",&t);
while(t--)
{
scanf("%d",&m);
switch(n[m%294])
{
case 0:
{
printf("Saturday\n");
}
break;
case 1:
{
printf("Sunday\n");
}
break;
case 2:
{
printf("Monday\n");
}
break;
case 3:
{
printf("Tuesday\n");
}
break;
case 4:
{
printf("Wednesday\n");
}
break;
case 5:
{
printf("Thursday\n");
}
break;
case 6:
{
printf("Friday\n");
}
break;
}
}
return 0;
}