結果
問題 | No.721 Die tertia (ディエ・テルツィア) |
ユーザー |
![]() |
提出日時 | 2018-08-03 23:04:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 78,540 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 17:38:14 |
合計ジャッジ時間 | 1,403 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d/%d/%d", &y, &m, &d); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> using namespace std; typedef long long int ll; typedef pair<int, int> P; int main() { int y, m, d; scanf("%d/%d/%d", &y, &m, &d); bool e=0; if(y%4==0 && y%100!=0){ e=1; }else if(y%400==0){ e=1; } int dmax[13]; for(int i=1; i<=12; i++){ if(i==2 && e){ dmax[i]=29; }else if(i==2 && !e){ dmax[i]=28; }else if(i==4 || i==6 || i==9 || i==11){ dmax[i]=30; }else{ dmax[i]=31; } } int y1, m1, d1; if(d+2<=dmax[m]){ y1=y, m1=m, d1=d+2; }else{ y1=y, m1=m+1, d1=d+2-dmax[m]; if(m1==13){ m1=1; y1++; } } cout<<y1<<"/"; if(m1<10){ cout<<0; } cout<<m1<<"/"; if(d1<10){ cout<<0; } cout<<d1<<endl; return 0; }