T2196.占星家的任务
2023-08-03 10:10:21
发布于:浙江
#include<bits/stdc++.h>
using namespace std;
int y,m,d,t,n;
int rn(int x){
if(x % 400 == 0||x % 4 == 0&&x % 100 != 0) return 1;
else return 0;
}
void f(){
for(int i = 1;i <= n;i++){
d++;
if(m == 1||m == 3||m == 5||m == 7||m == 8||m == 10||m == 12){
if(d == 32){
d = 1,m++;
if(m == 13) m = 1,y++;
}
}
if(m == 4||m == 6||m == 9||m == 11){
if(d == 31){
d = 1,m++;
if(m == 13) m = 1,y++;
}
}
if(m == 2){
if(rn(y)){
if(d == 30) d = 1,m++;
}else{
if(d == 29) d = 1,m++;
}
}
}
}
int main(){
cin >> t;
for(int i = 1;i <= t;i++){
scanf("%d-%d-%d",&y,&m,&d);
cin >> n;
n--;
f();
printf("%d-%d-%d\n",y,m,d);
}
return 0;
}
这里空空如也
有帮助,赞一个