Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
47Ms暴力gcc,真是日了狗的题。。#include<stdio.h> main() { int i=1,h=1; int num1,num2,num3,num4,peak; scanf("%d %d %d %d",&num1,&num2,&num3,&num4); while(num1!=-1||num2!=-1||num3!=-1||num4!=-1) { num1=num1%23; num2=num2%28; num3=num3%33; peak=num3+33; if(num1==num2&&num2==num3&&num1>num4) { peak=num1-num4; h=0; } if(num1==num2&&num2==num3&&num1<=num4) { peak=num1+21252-num4; h=0; } //peak=num3+33; while(h) { while(((peak-num1)%23)!=0||((peak-num2)%28)!=0||peak-num4<0) peak+=33; peak=peak-num4; break; } printf("Case %d: the next triple peak occurs in %d days.\n",i,peak); h=1;i++;scanf("%d %d %d %d",&num1,&num2,&num3,&num4); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator