TQL移步大神讲解
POJ1006
AC:
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define EPS 1E-10
using namespace std;
void exgcd(int a,int b,int &g,int &x,int &y)
{
if(!b)
{
g=b; x=1; y=0;
}
else
{
exgcd(b,a%b,g,y,x); y-=x*(a/b);
}
}
int main()
{
const int M=23*28*33;
int p,e,i,d;
int k=0;
while(1)
{
scanf("%d%d%d%d",&p,&e,&i,&d);
if(p==-1 && e==-1 && i==-1 &&d==-1)
break;
int s=(M/23*6*p+M/28*19*e+M/33*2*i-d+M)%M;
if(!s)
s=21252;
printf("Case %d: the next triple peak occurs in %d days.\n",++k,s);
}
return 0;
}