# 生理周期

Description

Input

Output

Sample Input

4 5 6 7

Sample Output

16994

#include<stdio.h>
int main()
{
int p, e , i ,d;
int j ;
scanf("%d%d%d%d",&p,&e,&i,&d);
for( j=d+1;j<21252;j++)
if( (j-p)%23==0 ) break;
for(;j<21252;j=j+23)
if( (j-e)%28==0 )	break;
for(;j<21252;j=j+23*28)
if( (j-i)%33==0 )	break;
printf("%d",j-d);
}

# 假币问题

Descrip

Input

Output

Sample Input

1
ABCD EFGH even
ABCI EFJK up
ABIJ EFGH even

#include<stdio.h>
#include<string.h>
char left[3][7],right[3][7],result[3][5];
bool isHeavy(char);
bool isLight(char);
int main()
{
int n;
char c;
scanf("%d",&n);
while(n>0){
for(int i=0;i<3;i++)
scanf("%s%s%s",left[i],right[i],result[i]);
for(c='A';c<='L';c++){
if(isLight(c)){
printf("%c is the counterfeit coin and it is light.\n",c);
break;
}
if(isHeavy(c)){
printf("%c is the counterfeit coin and it is heavy.\n",c);
break;
}
}
n--;
}
}
bool isLight(char x)
{
int i;
for(i=0;i<3;i++)
switch(result[i][0]){
case'u':if(strchr(right[i],x)==NULL)
return false;
break;
case'e':if(strchr(right[i],x)!=NULL||strchr(left[i],x)!=NULL)
return false;
break;
case'd':if(strchr(left[i],x)==NULL)
return false;
break;
}
return true;
}
bool isHeavy(char x){
int i;
for(i=0;i<3;i++)
switch(result[i][0]){
case'u':if(strchr(left[i],x)==NULL)
return false;
break;
case'e':if(strchr(right[i],x)!=NULL||strchr(left[i],x)!=NULL)
return false;
break;
case'd':if(strchr(right[i],x)==NULL)
return false;
break;
}
return true;
}

# 完美立方

Descrip

Input

Output

Cube = a, Triple = (b,c,d)

Sample Input

24

Sample Output

Cube = 6, Triple = (3,4,5)
Cube = 12, Triple = (6,8,10)
Cube = 18, Triple = (2,12,16)
Cube = 18, Triple = (9,12,15)
Cube = 19, Triple = (3,10,18)
Cube = 20, Triple = (7,14,17)
Cube = 24, Triple = (12,16,20)

#include<stdio.h>
#include<math.h>
int main()
{
int a, b,c ,d,n;
long int cube[101];
scanf("%d",&n);
for(int i=1;i<=n;i++)
cube[i]=i*i*i;
for(a=6;a<=n;a++)
{
for(b=2;b<a-1;b++){
if(cube[a]<cube[b]+cube[b]+cube[b+1]) break;
for(c=b+1;c<a;c++){
if(cube[a]<cube[b]+cube[c]+cube[c+1])	break;
for(d=c+1;d<a;d++)
{
if(cube[a]==cube[b]+cube[c]+cube[d])
printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d);
}
}
}
}
return 0;
}

# 数字方格

Descrip

Input

Output

Sample Input

3

Sample Output

5

#include<stdio.h>
int main()
{
int n,j=0;int i;
int a1,a2,a3;
int max[1000000]={0};
scanf("%d",&n);
for(a1=0;a1<=n;a1++)
{
for(a2=0;a2<=n;a2++)
{
for(a3=0;a3<=n;a3++)
{
if((a1+a2)%2==0&&(a2+a3)%3==0&&(a1+a2+a3)%5==0)
{
max[j++]=a1+a2+a3;
}
}
}
}
int a=max[0];
for(i=1;i<j;i++){
if(a<max[i])	a=max[i];
}
printf("%d",a);
}

©️2019 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客