1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=1e6; int vis[N],arr[N]; void check() { memset(vis,0,sizeof(vis)); memset(arr,0,sizeof(arr)); for(int i=1998;i<10000;i++) { if((i%4==0&&i%100!=0)||(i%100==0&&i%400==0)) vis[i]=1; } arr[1]=4,arr[2]=5,arr[3]=6,arr[4]=7; for(int j=5;j<10000;) { for(int r=1;r<=7;r++) { arr[j]=r; j++; } } } int main() { check(); int n,sum=0; int s1[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int s2[12]={31,29,31,30,31,30,31,31,30,31,30,31}; cin>>n; for(int i=1998;i<n;i++) { if(vis[i]) sum+=366; else sum+=365; } int k=0; int day=13+sum; if(arr[day]==5) k++; if(vis[n]) { for(int i=0;i<11;i++) { day+=s2[i]; if(arr[day]==5) k++; } } else { for(int i=0;i<11;i++) { day+=s1[i]; if(arr[day]==5) k++; } } cout<<k<<endl; return 0; }
- 1
Information
- ID
- 1189
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 9
- Tags
- # Submissions
- 12
- Accepted
- 4
- Uploaded By