令 为 , 为 。
-
如果 且 :
- 若 :
- 若 ,就在输出时,分别在 和 之前加上 。
- 否则,就在 前加上 。
- 若 :
- 若 ,就在输出时,在 之前加上 。
- 否则,就直接输出 和 。
- 若 :
-
如果 且 :
- 若 :
- 若 ,就在输出时,分别在 和 之前加上 。
- 否则,就在 前加上 。
- 若 :
- 若 ,就在输出时,在 之前加上 。
- 否则,就直接输出 和 。
- 若 :
-
如果以上条件都没达成,输出 。
AC Code
#include<bits/stdc++.h>
#define int long long
#define rest(i,n,m) for(int i=n;i<=m;i++)
using namespace std;
int T;
signed main(void){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
rest(i,1,T){
int h,m;
cin>>h>>m;
if(h>=0 and h<=23 and m>=0 and m<=59){
if(h<10){
if(m<10) cout<<"0"<<h<<":"<<"0"<<m<<endl;
else cout<<"0"<<h<<":"<<m<<endl;
continue;
}else{
if(m<10) cout<<h<<":"<<"0"<<m<<endl;
else cout<<h<<":"<<m<<endl;
continue;
}
}
if(m>=0 and m<=23 and h>=0 and h<=59){
if(m<10){
if(h<10) cout<<"0"<<m<<":"<<"0"<<h<<endl;
else cout<<"0"<<m<<":"<<h<<endl;
continue;
}else{
if(h<10) cout<<m<<":"<<"0"<<h<<endl;
else cout<<m<<":"<<h<<endl;
continue;
}
}
else cout<<"-1"<<endl;
}
exit(0);
}
暂无评论