Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
58 lines (50 loc) · 1.32 KB

File metadata and controls

58 lines (50 loc) · 1.32 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
ID: xieke.b1
PROB: friday
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
using namespace std;
int N;
int d_in_m[13] = {-1,31,-1,31,30,31,30,31,31,30,31,30,31};
int fri_13[13];;
int main(){
ofstream fout("friday.out");
ifstream fin("friday.in");
while(fin>>N){
memset(fri_13,0,sizeof(fri_13));
int cnt = 1;
for(int year=1900; year<1900+N; year++){
for(int month=1; month<=12; month++){
int days;
if(month==2){
if((year%100!=0 &&year%4==0) || (year%100==0 && year%400==0 ) ){
days = 29;
}else{
days = 28;
}
}else{
days = d_in_m[month];
}
cout<<"year "<<year<<" month "<<month<<" days "<<days<<endl;
for(int i=1; i<=days; i++){
cnt+=1;
cnt%=7;
if(i==13){
fri_13[cnt]++;
}
}
}
}
for(int i=0; i<6; i++){
fout<<fri_13[i]<<" ";
//cout<<fri_13[i]<<" ";
}
//cout<<fri_13[6]<<endl;
fout<<fri_13[6]<<endl;
}
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.