2018西北工业大学夏令营第三题
程序员文章站
2022-03-09 22:38:21
...
每种情况单独考虑就行
#include<iostream>
using namespace std;
int main(){
/*
5
2018 07 02 08 22
2018 07 01 08 21
2018 01 01 00 00
2018 03 01 00 00
2016 03 01 00 00
*/
int n,y,m,d,h,f;
cin>>n;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
for(int i = 0;i < n;i++){
cin>>y>>m>>d>>h>>f;
//需要跨越年份
if(m==1&&d==1&&h<16){
printf("%d %02d %02d %02d %02d\n",y-1,12,31,24+h-16,f);
continue;
}
//二月单独考虑
if(m==3&&d==1&&h<16){
if((y%400==0)||(y%100!=0&&y%4==0)){
printf("%d %02d %02d %02d %02d\n",y,2,29,24+h-16,f);
}else{
printf("%d %02d %02d %02d %02d\n",y,2,28,24+h-16,f);
}
continue;
}
//需要跨月份
if(d==1&&h<16){
printf("%d %02d %02d %02d %02d\n",y,m-1,a[m-1],24+h-16,f);
continue;
}
//需要跨日期
if(h<16){
printf("%d %02d %02d %02d %02d\n",y,m,d-1,24+h-16,f);
continue;
}
printf("%d %02d %02d %02d %02d\n",y,m,d,h-16,f);
}
return 0;
}
上一篇: CTF之隐写术总结