2019新生赛
程序员文章站
2022-06-09 16:08:34
...
1
#include<stdio.h>
#include<string.h>
int main()
{
int T,t=1;
scanf("%d",&T);
while(T--)
{
char a[1005];
scanf("%s",a);
int i,len=strlen(a);
if(len%2!=0)
printf("Case# %d: No\n",t++);
else
{
int flag=0;
for(i=len/2-1;i>=0;i--)
{
if(a[i]==a[i-1])
{
int j1=i-1,j2=i;
while(j1!=0)
{
if(a[j1]!=a[j2])
break;
j1--;
j2++;
}
if(j1==0)
{
int j1=2*i,j2=len-1;
while(j1<j2)
{
if(a[j1]!=a[j2])
break;
j1++;
j2--;
}
if(j1>j2)
{
flag=1;
printf("Case# %d: Yes\n",t++);
break;
}
}
}
}
if(flag==0)
printf("Case# %d: No\n",t++);
}
}
return 0;
}
2
#include<stdio.h>
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,k;
scanf("%d%d",&n,&k);
long long i,a[1005],f[1005];
a[1]=1;
for(i=2;i<n;i++)
a[i]=a[i-1]+i;
f[1]=k;
for(i=2;i<=n;i++)
f[i]=f[i-1]+a[i-1];
printf("%lld\n",f[n]);
}
return 0;
}
3
#include<stdio.h>
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m,k;
int ans=0;
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if((i+j)%k==0)
ans++;
}
printf("%d\n",ans);
}
return 0;
}
4
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int a[205][205];
int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
int s[205]={0};
for(i=0;i<n;i++)
scanf("%d",&s[i]);
int t1,t2,ans=0;
for(i=0;i<n;i++)
{
while(s[i]!=1&&i<n)
i++;
t1=i;
while(s[i]!=0&&i<n)
i++;
i--;
t2=i;
if(t1<=t2)
ans+=a[t1][t2];
}
printf("%d\n",ans);
return 0;
}
5
#include<stdio.h>
int main()
{
printf("The problem of this contest is very easy.I can AK.\n");
printf("The problem of this contest is very easy.I can AK.\n");
printf("The problem of this contest is very easy.I can AK.\n");
}
6
#include<stdio.h>
int main()
{
printf("The problem of this contest is very easy.I can AK.\n");
printf("The problem of this contest is very easy.I can AK.\n");
printf("The problem of this contest is very easy.I can AK.\n");
}
7
#include<stdio.h>
int gcd(int a,int b)
{
if(a%b==0)
return b;
return gcd(b,a/b);
}
int main()
{
int n,i;
int a[105],b[105];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
scanf("%d",&b[i]);
int ans=1,max=0;
for(i=0;i<n;i++)
{
int m;
if(ans<a[i])
m=gcd(a[i],ans);
else
m=gcd(ans,a[i]);
ans=ans*a[i]/m;
// printf("%d %d %d\n",m,ans,max);
if(max<b[i])
max=b[i];
}
for(i=0;i<n;i++)
if(max!=b[i])
break;
if(i!=n)
printf("%d\n",max+ans);
else
printf("%d\n",max);
return 0;
}
8
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,j;
scanf("%d",&n);
char a[1005][1005];
for(i=0;i<n;i++)
scanf("%s",a[i]);
char str[1005];
scanf("%s",str);
int ans=0;
for(i=0;i<strlen(str);i++)
{
str[i]-='0';
if(str[i]==4)
ans+=-1;
else if(str[i]==5)
ans+=-2;
else if(str[i]==6)
ans+=-3;
else
ans+=str[i];
ans%=4;
}
if(ans==0)
{
for(i=0;i<n;i++)
printf("%s\n",a[i]);
}
else if(ans==1)
{
for(i=0;i<n;i++)
{
for(j=n-1;j>=0;j--)
printf("%c",a[j][i]);
printf("\n");
}
}
else if(ans==2)
{
for(i=n-1;i>=0;i--)
printf("%s\n",a[i]);
}
else
{
for(i=n-1;i>=0;i--)
{
for(j=0;j<n;j++)
printf("%c",a[j][i]);
printf("\n");
}
}
return 0;
}
9
#include<stdio.h>
int main()
{
double a,b,c,d;
while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d)!=EOF)
{
double v=(b+c)/d;
double t=(a+c)/v;
printf("%.2f %.2f\n",v,t);
}
return 0;
}
10
#include<stdio.h>
#include<math.h>
struct node{
int x,y,r;
}a[1005];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,i;
int bx,by,ex,ey;
scanf("%d%d%d%d%d",&n,&bx,&by,&ex,&ey);
for(i=0;i<n;i++)
scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r);
int flag=0;
for(i=0;i<n;i++)
{
int xx=fabs(bx-a[i].x)*fabs(bx-a[i].x);
int yy=fabs(by-a[i].y)*fabs(by-a[i].y);
double dis=sqrt(xx*1.0+yy*1.0);
if(a[i].r*1.0-dis>0.0000000001)
{
int xxx=fabs(ex-a[i].x)*fabs(ex-a[i].x);
int yyy=fabs(ey-a[i].y)*fabs(ey-a[i].y);
double R=sqrt(xxx*1.0+yyy*1.0);
if(a[i].r*1.0-R>0.0000000001)
flag++;
}
else
{
int xxx=fabs(ex-a[i].x)*fabs(ex-a[i].x);
int yyy=fabs(ey-a[i].y)*fabs(ey-a[i].y);
double R=sqrt(xxx*1.0+yyy*1.0);
if(R-a[i].r*1.0>0.0000000001)
flag++;
}
}
if(flag!=n) printf("No\n");
else printf("Yes\n");
}
return 0;
}