# 3004. 生理高峰

10165101258的这位老哥，你i%33后面的括号是中文的。。。。。。

### include

int main()
{
int t,y;
scanf(“%d”,&t);
for(y=0;y<t;y++){
int p,e,i,d,x,j,k;
scanf(“%d%d%d%d”,&p,&e,&i,&d);
for(j=d+1;j<=21252;j++){
if((j-p)%23==0) break;
}
for(k=j;k<=212522;k+=23){
if((k-e)%28==0) break;
}
for(x=k;x<=21252;x+=23*28){
if((x-i)%33==0) break;
}
printf(“case #%d:\n”,y);
printf(“the next triple peak occurs in %d days.\n”,x-d);
}
return 0;
}

### include

int main()
{
int cases;
scanf(“%d”,&cases);
int c;
for(c=0;c<cases;c++)
{
int p,e,i,d;
int num;
scanf(“%d %d %d %d”,&p,&e,&i,&d);
printf(“case #%d:\n”,c);
for(num=1;num<=21252;num++)
if((num%23)==p%23)
if((num%28)==e%28)
if((num%33)==i%33）
{
printf(“the next triple peak occurs in %d days.\n”,num-d);
break;
}
}
return 0;
}

+1.千万不要直愣愣地给循环加上限为21252，这是个坑。

#include <stdio.h>
int main()
{
int T, I;
scanf("%d",&T);
for(I=0; I<T; I++)
{
int p, e, i, d, n, x[22000]={0};
scanf("%d %d %d %d",&p,&e,&i,&d);
for(n=-40; p+23*n<22000; n++) if(p+23*n>0) x[p+23*n]++;
for(n=-40; e+28*n<22000; n++) if(e+28*n>0) x[e+28*n]++;
for(n=-40; i+33*n<22000; n++) if(i+33*n>0) x[i+33*n]++;
for(n=0; n<22000; n++) if(x[n]==3 && n>d) {printf("case #%d:\nthe next triple peak occurs in %d days.\n",I,n-d); break;}
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int arr[3];
int mm[3];
int c_time = 0;
int extend_gcd(int a, int b, int &x, int &y)
{
if(b == 0){
x = 1;
y = 0;
return a;
}  else {
int r = extend_gcd(b,a%b,y,x);
y -= x*(a/b);
return r;
}
}

int CRT(int a[], int m[], int n)
{
int x = 0,y = 0;
int M = 1;
for (int i = 0 ; i < n ; ++i) M *= m[i];
int ret = 0;
for (int i = 0 ; i < n ; ++i){
int tm = M / m[i];
extend_gcd(tm,m[i],x,y);
ret = (ret + tm*x*a[i])%M;
}
ret = ret%M;
while(ret <= c_time)
ret += M;
return ret;
}

int main()
{
mm[0] = 23; mm[1] = 28 ; mm[2] = 33;
int T = 0;
int cc = 0;
int getTime = 0;
scanf("%d",&T);
while(T--){
scanf("%d%d%d%d",&arr[0],&arr[1],&arr[2],&c_time);
getTime = CRT(arr,mm,3);
printf("case #%d:\nthe next triple peak occurs in %d days.\n",cc++,getTime-c_time);
}
return 0;
}