結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー mmn15277198
提出日時 2020-06-03 19:41:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 08:50:15
合計ジャッジ時間 1,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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