-
Notifications
You must be signed in to change notification settings - Fork 0
/
P1340.cpp
84 lines (71 loc) · 1.53 KB
/
P1340.cpp
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
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int convert_month(string m) {
if(m == "January") {
return 1;
}
if(m == "February") {
return 2;
}
if(m == "March") {
return 3;
}
if(m == "April") {
return 4;
}
if(m == "May") {
return 5;
}
if(m == "June") {
return 6;
}
if(m == "July") {
return 7;
}
if(m == "August") {
return 8;
}
if(m == "September") {
return 9;
}
if(m == "October") {
return 10;
}
if(m == "November") {
return 11;
}
if(m == "December") {
return 12;
}
return 0;
}
int main() {
cin.tie(NULL);
cout.tie(NULL);
string str_month;
int month, day, year, hour, min;
cin >> str_month;
scanf("%d, %d %d:%d", &day, &year, &hour, &min);
month = convert_month(str_month);
if((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) months[1] = 29;
// 윤년 계산
int total_year = 0, total_sec = 0;
for(int i = 0; i < 12; i++) total_year += months[i];
total_sec = total_year * 24 * 3600;
// year to second
int m = 0;
for(int i = 0; i < month - 1; i++) {
m += months[i];
}
m += day - 1;
m *= 86400;
// month + day to second
hour *= 3600;
min *= 60;
// hour, min to second
printf("%.9lf", ((double)(m + hour + min) / (double)total_sec) * 100);
return 0;
}