AcWing 3391. 今年的第几天?
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int Y,M,D;
int m[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31};
bool isleapyear(int x){
return x%4==0&&(x%100||(x%400==0));
}
void solve(){
while(cin>>Y>>M>>D){
if(isleapyear(Y))m[2]=29;
else m[2]=28;
int d = 0;
for(int i = 1;i<=M-1;i++)d+=m[i];
d+=D;
cout<<d<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}