一个小模拟 愣是写了一个钟头...
先上代码 再说启示
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 10000;
int H,M,x,y,t;
char tmp;
int mir[10]={0,1,5,-1,-1,2,-1,-1,8,-1};
bool check(int x,int y)
{
int a,b,c,d;
a=mir[x/10],b=mir[x%10],c=mir[y/10],d=mir[y%10];
if(a==-1||b==-1||c==-1||d==-1) return false;
return d*10+c<H && b*10+a<M;
}
int main()
{
ios::sync_with_stdio(false);
cin>>t;
while(t--)
{
cin>>H>>M;
cin>>x>>tmp>>y;
while(1)
{
if(check(x,y))
{
cout<<x/10<<x%10<<":"<<y/10<<y%10<<endl;
break;
}
y=(y+1)%M;
if(y==0) x=(x+1)%H;
}
}
}
原文:https://www.cnblogs.com/JOoooo/p/14493983.html