結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
chacoder1
|
| 提出日時 | 2020-11-22 16:14:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,512 bytes |
| コンパイル時間 | 2,343 ms |
| コンパイル使用メモリ | 195,288 KB |
| 最終ジャッジ日時 | 2025-01-16 04:25:10 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string S;
cin>>S;
int uru=0;
int YY=(S.at(0)-'0')*1000;
YY+=(S.at(1)-'0')*100;
YY+=(S.at(2)-'0')*10;
YY+=(S.at(3)-'0');
int MM=(S.at(5)-'0')*10;
MM+=S.at(6)-'0';
int DD=(S.at(8)-'0')*10;
DD+=S.at(9)-'0';
//cout<<YY<<MM<<DD<<endl;
DD+=2;
/*uru hantei*/
if((YY%4==0 && YY%100 != 0 )|| YY%400 ==0){
uru=1;
}
//うるう年の2月
if((uru==1 && MM==2 )&& DD>29){
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM+1<<"/"<<setfill('0')<<right<<setw(2)<<DD-29<<endl;
return 0;
}
//うるう年でない2月
if(uru==0 && MM==2 && DD>28){
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM+1<<"/"<<setfill('0')<<right<<setw(2)<<DD-28<<endl;
return 0;
}
//年末
if(MM==12 && DD>31){
DD-=31;
MM=1;
YY++;
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM<<"/"<<setfill('0')<<right<<setw(2)<<DD<<endl;
return 0;
}
//大の月 月末
if((MM==1||MM==3||MM==5||MM==7||MM==8||MM==10)&&(DD>31)){
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM+1<<"/"<<setfill('0')<<right<<setw(2)<<DD-31<<endl;
return 0;
}
//小の月 月末
if(!(MM==1||MM==3||MM==5||MM==7||MM==8||MM==10)&&(DD>30)){
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM+1<<"/"<<setfill('0')<<right<<setw(2)<<DD-30<<endl;
return 0;
}
//繰り上がり処理不要
cout<<YY<<"/"<<setfill('0')<<right<<setw(2)<<MM<<"/"<<setfill('0')<<right<<setw(2)<<DD<<endl;
return 0;
}
chacoder1