A计划--POJ1006 Biorhythms

来源:互联网 发布:c语言表白代码立体爱心 编辑:程序博客网 时间:2024/06/04 00:26

A题不分早晚!

第一道枚举水题

import java.util.Scanner;public class Main{public static void main(String[] args) {   Scanner sc = new Scanner(System.in);       int p,e,i,d;       int m =1;       while((p=sc.nextInt())!=-1&&(e=sc.nextInt())!=-1&&(i=sc.nextInt())!=-1&&(d=sc.nextInt())!=-1){       sc.nextLine();       int x = d+1;       for(;x<=21252;x++){       if((x-p)%23==0)        break;       }       for(;x<=21252;x+=23){       if((x-e)%28==0)       break;       }       for(;x<=21252;x+=28*23){       if((x-i)%33==0)       break;       }       System.out.println("Case "+(m++)+": the next triple peak occurs in "+(x-d)+" days.");       }}}