QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#658863 | #7176. I Flipped The Calendar... | sadat | ML | 0ms | 0kb | C++14 | 1.3kb | 2024-10-19 17:48:46 | 2024-10-19 17:48:47 |
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define inp cin>>
#define out cout<<
#define ii >>
#define oo <<
#define nl <<"\n"
#define br cout<<"\n"
#define spc <<" "
#define space <<" "<<
#define loop(n) for(ll i=0; i<(n); i++)
#define fr(i,init, n) for(ll i=(init); i<(n); i++)
int numLeap(int year){ // inclusive
return (year / 4) - (year / 100) + (year / 400) ;
}
bool isleap(int year){
if(year%400==0) return true;
if(year%100==0) return false;
if(year%4==0) return true;
return false;
}
int getrem(int year){
year--;
int days = year*365 + numLeap(year);
int rem = days%7;
}
void SOLVE(){
int year; inp year;
int rem = getrem(year);
int dayinmonth[]= {31,28,31,30,31,30,31,31,30,31,30,31};
if(isleap(year)) dayinmonth[1]++;
int m = 12;
int ans =0;
loop(m){
int day = dayinmonth[i];
if(rem<7) day+=rem;
int week = day/7;
rem = day%7;
if(rem) week++;
ans+=week;
}
out ans nl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
// cin>>t;/////////////////////
while(t--) SOLVE();
return 0;
}
/*
starting day
number of days = 365*years + numleap
leap year
divisible by 400 : true
divisible by 100 : false
by 4 : true
false
*/
详细
Test #1:
score: 0
Memory Limit Exceeded
input:
2023