题目2571:蓝桥杯2020年第十一届省赛真题-回文日期

#include<iostream>

using namespace std;

bool ispre(int day){

string s;

while(day){

s+=day%10+'0';

day/=10;

}

for(int i=0,j=7;i<j;i++,j--){

if(si!=sj){

return false;

}

}

return true;

}

bool isAB(int day){

string s;

while(day){

s+=day%10+'0';

day/=10;

}

if(s0==s2&&s1==s3){

return true;

}

return false;

}

int main(){

int time;

cin>>time;

int monthdays\[\]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int res;

int flag=0;

for(int year=1000;year<=9999;year++){

//遍历每一天,判断是否为回文数和AB

if(year*10000+10000<time){

continue;

}

for(int month=1;month<=12;month++){

int days=monthdaysmonth;

if(month==2){

//闰年二月加一天

if((year%400==0)||(year%4==0&&year%100!=0)){//闰年判断

days++;

}

}

for(int i=1;i<=days;i++){

int day=i+month*100+year*10000;

if(ispre(day)){

if(day<=time){

continue;

}

if(flag==0){

res=day;

flag=1;

}

if(isAB(day)){

cout<<res<<endl<<day<<endl;

return 0;

}

}

}

}

}

return 0;

}

相关推荐
程与留2 小时前
15_国际化和本地化:tr()、ts 文件、QM 文件、多语言切换
c++·qt
地平线开发者3 小时前
【模型轻量化专题】衡量模型轻量性的指标
算法
程与留3 小时前
14_Qt 样式表(QSS)入门(语法、选择器、美化实战)
c++·qt
学习星球6 小时前
OFDM技术精讲:正交性推导、循环前缀原理与80行Python链路仿真(附实测数据)
算法·面试·前端框架
欧特克_Glodon12 小时前
OpenCV计算机视觉开发入门与实践<二十七>:图像分割概述
c++·人工智能·opencv·计算机视觉
蒸蒸yyyyzwd12 小时前
cpp 选手秋招学习笔记 day21
c++·面试·八股
alphaTao12 小时前
LeetCode 每日一题 2026/8/24-2026/8/30
python·算法·leetcode
Interview Aid11212 小时前
TikTok OA 四题分享|半小时内 AC,题目基本都是实现题
java·开发语言·算法·面试·职场和发展
顶点多余1 天前
那些在算法中适合巩固的知识点---1
java·前端·算法
AI情绪识别开源1 天前
检信 ALLEMOTION OS 加密打包可执行程序 — 全面测试报告版本: v1.3功能测试 / 性能测试 /
开发语言·数据结构·人工智能·功能测试