# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238415 | stev2005 | Datum (COCI20_datum) | C++17 | 62 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
/*struct date
{
string d,m,y;
void input()
{
cin>>d;
}
};
date in,ans;*/
string in,ans;
int d,y,m,n;
void init()
{
/*day: 0-1
month: 3-4
year: 6-9*/
d=((int)in[0]-(int)'0')*10+((int)in[1]-(int)'0');
m=((int)in[3]-(int)'0')*10+((int)in[4]-(int)'0');
y=((int)in[6]-(int)'0')*1000+((int)in[7]-(int)'0')*100;
y+=(((int)in[8]-(int)'0')*10+((int)in[9]-(int)'0'));
}
bool check(int ty)
{
if(d==0||m==0)return false;
/// 31: 1,3,5,7,8,10,12
if(m>12)return false;
if(m==2)
{
if(d<=28)return true;
else
{
if(d<=29)
{
if(ty%4==0)return true;
else return false;
}
else return false;
}
}
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
{
if(d<=31)return true;
else return false;
}
else
{
if(d<=30)return true;
else return false;
}
}
void solve()
{
int ed,des,st,hil;
for(int i=y+1;i<=9999;i++)
{
ed=i%10;
des=i/10%10;
st=i/100%10;
hil=i/1000%10;
d=ed*10+des;
m=hil+st*10;
if(check(i))
{
y=i;
return;
}
}
}
void print()
{
string ans="",t="";
char c;
c=((char)(d/10%10+(int)'0'));
ans+=c;
c=((char)(d%10+(int)'0'));
ans+=c;ans+='.';
c=((char)(m/10%10+(int)'0'));
ans+=c;
c=((char)(m%10+(int)'0'));
ans+=c;ans+='.';
c=((char)(y/1000%10+(int)'0'));
ans+=c;
c=((char)(y/100%10+(int)'0'));
ans+=c;
c=((char)(y/10%10+(int)'0'));
ans+=c;
c=((char)(y%10+(int)'0'));
ans+=c;ans+='.';
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>in;
init();
solve();
print();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |