import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int count=1;
while(sc.hasNext()){
int p=sc.nextInt();
int e=sc.nextInt();
int i=sc.nextInt();
int d=sc.nextInt();
if(p==-1&&e==-1&&i==-1&&d==-1){
break;
}
int yuand=d;
if(d==0){
d++;
while((d-p)%23!=0) d++;
int oriday=d;
while(oriday<=d+21252){
if((oriday-e)%28==0){
if((oriday-i)%33==0){
System.out.println("Case "+(count++)+": the next triple peak occurs in "+(oriday-yuand)+" days.");
break;
}
}
oriday+=23;
}
}else{
while((d-p)%23!=0) d++;
int oriday=d;
while(oriday<=d+21252){
if((oriday-e)%28==0){
if((oriday-i)%33==0){
System.out.println("Case "+(count++)+": the next triple peak occurs in "+(oriday-yuand)+" days.");
break;
}
}
oriday+=23;
}
}
}
}
}
poj1006
最新推荐文章于 2021-02-13 19:58:12 发布