您的位置:首页 > 其它

ZOJ 1160 历法水题

2011-05-13 21:11 267 查看
题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=160

可以直接暴力

#include<stdio.h>

int main()
{
int d,p,i,e,x,t;
int temp1,temp2,temp3;
scanf("%d",&t);
while(t--)
{
int cnt=1;
while(scanf("%d%d%d%d",&p,&e,&i,&d)!=EOF)
{
if(p==-1&&e==-1&&i==-1&&d==-1)
break;
for(x=21252;x>=0;x--)
{
temp1=(x+d-p)%23;
temp2=(x+d-e)%28;
temp3=(x+d-i)%33;
if(temp1==0&&temp2==0&&temp3==0)
{
printf("Case %d: the next triple peak occurs in %d days./n",cnt++,x);
break;
}
}
}
if(t)
printf("/n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: