-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUSACO4.java
More file actions
91 lines (72 loc) · 2.3 KB
/
USACO4.java
File metadata and controls
91 lines (72 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
ID: achyuta2
LANG: JAVA
TASK: friday
*/
import java.io.*;
class friday {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new FileReader("friday.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("friday.out")));
int i0 = Integer.parseInt(f.readLine());
System.out.println(i0);
String [] days ={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
int [] months ={31,28,31,30,31,30,31,31,30,31,30,31};
int [] monthsLeap ={31,29,31,30,31,30,31,31,30,31,30,31};
int n =0;
for(int year = 1900; year<(1900+i0);year++){
if(isLeap(year)){
for (int daynum:monthsLeap){
out.println(days[n]);
n=(n+daynum)%7;
}
}
else{
for (int daynum1:months){
out.println(days[n]);
n=(n+daynum1)%7;
}
}
}
out.close();
BufferedReader s = new BufferedReader(new FileReader("friday.out"));
int sun = 0,mon = 0,tue = 0,wed = 0,thu = 0,fri = 0,sat = 0;
for(int q=0; q<(12*i0); q++ ){
String y = s.readLine();
switch (y){
case "Sun":
sun+=1;
break;
case "Mon":
mon+=1;
break;
case "Tue":
tue+=1;
break;
case "Wed":
wed+=1;
break;
case "Thu":
thu+=1;
break;
case "Fri":
fri+=1;
break;
case "Sat":
sat+=1;
break;
}
}
PrintWriter r = new PrintWriter(new BufferedWriter(new FileWriter("friday.out")));
r.flush();
r.println(sun+" "+mon+" "+tue+" "+wed+" "+thu+" "+fri+" "+sat);
r.close();
}
public static boolean isLeap(int year){
if(year%100 == 0){
return year % 400 == 0;
}else{
return year % 4 == 0;
}
}
}