Poj Solution 1006

http://poj.org/problem?id=1006

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


											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *