結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-03 14:00:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,617 bytes |
| コンパイル時間 | 1,769 ms |
| コンパイル使用メモリ | 168,644 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 23:33:12 |
| 合計ジャッジ時間 | 2,807 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int trans(string s){
int n = s.size();
int t = 1;
int res = 0;
for(int i=n-1;i>=0;i--){
res += (s[i] - '0') * t;
t *= 10;
}
return res;
}
int main(){
string s;
cin >> s;
string y = s.substr(0,4);
string m = s.substr(5,2);
string d = s.substr(8,2);
int Y = trans(y);
int M = trans(m);
int D = trans(d);
if(Y%400 ==0 && M == 2 && D >= 27){
if(D == 27) D += 2;
else if(D == 28) D = 1,M ++;
else if(D == 29) D = 2,M ++;
}else if((Y%4 ==0 && Y%100 != 0)&& M == 2 && D >= 27){
if(D == 27) D += 2;
else if(D == 28) D = 1,M ++;
else if(D == 29) D = 2,M ++;
}else if((M == 4 || M == 6 || M == 9 || M ==11) && D >= 29){
D = (D + 2)%30;
M++;
}else if((M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M ==10|| M ==12) && D >= 30){
D = (D + 2)%31;
M ++;
if(M ==13){
M = 1;
Y ++;
}
}else if(M ==2 && D >= 27){
D = (D + 2)%28;
M ++;
}else{
D += 2;
}
if(M <= 9 && D <= 9) cout << Y << "/0" << M << "/0" << D << endl;
else if(M <= 9) cout << Y << "/0" << M << "/" << D << endl;
else if(D <= 9) cout << Y << "/" << M << "/0" << D << endl;
else cout << Y << "/" << M << "/" << D << endl;
return 0;
}