結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー mmn15277198mmn15277198
提出日時 2020-06-03 19:41:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 19:08:16
合計ジャッジ時間 1,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int day[14]={0,31,28,31,30,31,30,31,31,30,31,30,31,31};

int main(){
	string s;
	cin >> s;
	
	int y,m,d;
	y=0;
	m=0;
	d=0;
	
	int sls=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='/'){
			sls++;
			continue;
		}
		if(sls==0){
			y+=(int)(s[i]-'0');
			y*=10;
		}
		if(sls==1){
			m+=(int)(s[i]-'0');
			m*=10;
		}	
		if(sls==2){
			d+=(int)(s[i]-'0');
			d*=10;
		}	
	}
	y/=10;
	m/=10;
	d/=10;
	
	if(y%4==0)day[2]=29;
	if(y%100==0){
		if(y%400==0)day[2]=29;
		else day[2]=28;
	}
	
	d+=2;
	if(day[m]-d<0){
		d=d-day[m];
		m++;
		if(m==13){
			m=1;
			y++;
		}
	}
	
	string yy="",mm="",dd="";
	yy=to_string(y);
	
	if(m<10)mm="0";
	mm+=to_string(m);

	if(d<10)dd="0";
	dd+=to_string(d);
	
	cout << yy << "/" << mm << "/" << dd << endl;
	return 0;
}
0