题目连接: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; }
本文提供了一个针对ZJU ACM 160题目的解决方案,通过直接使用暴力搜索的方法来找到特定日期之后下一个三峰日的具体天数。代码中详细展示了如何通过循环遍历的方式逐一检查每个可能的日期。
1422

被折叠的 条评论
为什么被折叠?



