跳到正文

题解

B4191 题解

ikunTLE约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年2月8日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 2 分钟
获赞
4
题目
B4191

版本

  1. v1当前

题目传送门

思路

可以以分钟为单位进行枚举。

枚举起点为 T=(h×60+m+1) mod DT=(h\times60+m+1)\bmod D,每一次向后增加 11 分钟 T←(T+1) mod DT\gets(T+1)\bmod D。其中 DD 为常数,值为 D=24×60D=24\times60,代表一天的分钟数量。判断回文时再将 TT 拆开,令 X=⌊T60⌋X=\lfloor\frac{T}{60}\rfloor,Y=T mod 60Y=T\bmod60,即为当前的点数。如果满足 ⌊X10⌋=Y mod 10\lfloor\frac{X}{10}\rfloor=Y\bmod10 且 X mod 10=⌊Y10⌋X\bmod10=\lfloor\frac{Y}{10}\rfloor,则日期 X:Y\texttt{X:Y} 回文,输出即可。

AC CODE

C++
#include<bits/stdc++.h>
using namespace std;
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
const int D=24*60;
int main(){
	int a=read(),b=read();
	for(int t=(a*60+b+1)%D;;t=(t+1)%D){
		int x=t/60,y=t%60;
		if(x/10==y%10&&x%10==y/10)
			return printf("%02d:%02d\n",x,y),0;
	}
	return 0;
}
原文
存档评论2 条抓取于