跳到正文

题解

题解:P16210 [ECUSTPC 2025] 时间谜题

_ego_约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年5月16日
更新
2026年5月16日
篇幅
约 1 分钟
题目
P16210

版本

  1. v1当前

思路

只有两种可能:(a,b)(a,b) 或 (b,a)(b,a)。分别检查是否满足小时和分钟的范围,哪个合法输出哪个。都不合法输出 −1-1。

代码

C++
#include<bits/stdc++.h>
using namespace std;

int T,a,b;

int main(){
    cin>>T;
    while(T--){
        cin>>a>>b;
        if(a<24&&b<60){
            printf("%02d:%02d\n",a,b);
        }else if(b<24&&a<60){
            printf("%02d:%02d\n",b,a);
        }else{
            cout<<"-1\n";
        }
    }
    return 0;
}
原文