logo AlgoBeat OnlineJudge
登录 注册

「[ECUSTPC 2025] 时间谜题」题解

作者: Dr_KC_Haus  ·  发布于 2026-07-08 20:03:02  ·  最后修改于 2026-07-08 20:18:14
已通过
审核员:joe_zxq · 2026-07-08 20:18:14

  • 如果

      • ,就在输出时,分别在 之前加上
      • 否则,就在 前加上
      • ,就在输出时,在 之前加上
      • 否则,就直接输出
  • 如果

      • ,就在输出时,分别在 之前加上
      • 否则,就在 前加上
      • ,就在输出时,在 之前加上
      • 否则,就直接输出
  • 如果以上条件都没达成,输出

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);
} 

暂无评论

登录 后即可评论。