imped brute search (too slow)
[slick.co.git] / 1.1 / friday.java
blob0b65f55b0af4bda38885741af25ae20efa31d826
1 /*
2 ID: raincro1
3 LANG: JAVA
4 TASK: friday
5 */
6 import java.io.*;
7 import java.util.*;
9 class friday {
10 static class IO {
11 BufferedReader f;
12 StringTokenizer st;
13 public PrintWriter out;
15 public String line;
17 public IO () throws IOException {
18 f = new BufferedReader(new FileReader(name + ".in"));
19 out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".out")));
22 public String nextLine() throws IOException {
23 line = f.readLine();
24 st = null;
25 return line;
28 public int nextIntLine() throws IOException {
29 return Integer.parseInt(nextLine());
32 public void tokenize() {
33 st = new StringTokenizer(line);
36 public String nextToken() {
37 if(st == null) tokenize();
38 return st.nextToken();
41 public int nextIntToken() {
42 return Integer.parseInt(nextToken());
45 public void close() {
46 out.close(); // close the output file
47 System.exit(0); // don't omit this!
51 static boolean debug = true;
52 static String name = "friday";
54 static IO io;
56 public static void main (String [] args) throws IOException {
57 io = new IO();
59 int[] std = { 3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3 };
60 int[] leap = { 3, 1, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3 };
62 int total = io.nextIntLine();
64 int[] stat = { 0, 0, 0, 0, 0, 0, 0 };
66 int cur = 0;
68 for(int i = 0; i < total; i++){
69 int[] off = (i % 4 != 0) ? std : (i % 100 != 0) ? leap : (i % 400 != 100) ? std : leap;
71 // System.out.printf("%d %s: %d\n", i, off == leap ? "+" : "-", cur);
73 for(int j = 0; j < 12; j++){
74 stat[cur]++;
76 cur = (cur + off[j]) % 7;
80 for(int i = 0; i < 6; i++){
81 io.out.printf("%d ", stat[i]);
83 io.out.println(stat[6]);
85 io.close(); // close the output file