当前位置:网站首页>洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举
2022-07-02 22:53:00 【这题AC再睡.】
洛谷_P2010 [NOIP2016 普及组] 回文日期_折半枚举


//
#include<bits/stdc++.h>
using namespace std;
// 1 2 3 4 5 6 7 8 9 10 11 12
int mon[]={ 0,31,28,31,30,31,30,31,31,30,31,30,31 };
bool is_leap( int a )
{
return ( a%4==0 && a%100 || a%400==0 );
}
bool f( int a,int b,int c )
{
// cout<<a<<" "<<b<<" "<<c<<endl;
if( !( b>=1 && b<=12 ) ) return false; // b
int tt=mon[b];
if( b==2 ) tt+=is_leap(a);
return ( c>=1 && c<=tt ); // c
}
int main()
{
int x,y,t,tt,i,ans;
while( cin>>x>>y )
{
ans=0;
for( i=x/10000;i<=y/10000;i++ ) // tx ty 容易和后面 x y 混淆
{
t=i; tt=0;
while( t ) // 折半 翻转年份确保回文
{
tt=tt*10+t%10;
t/=10;
} // 前后的越界都要判断
if( i<=x/10000 && tt<x%10000 || i>=y/10000 && tt>y%10000 ) continue;
if( f( i,tt/100,tt%100 ) ) ans++;
}
cout<<ans<<endl;
}
return 0;
}边栏推荐
- Matlab 信号处理【问答笔记-1】
- Analyze ad654: Marketing Analytics
- Go basic data type
- [shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
- MFC 获取当前时间
- The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
- Why can't the start method be called repeatedly? But the run method can?
- 67 page overall planning and construction plan for a new smart city (download attached)
- MySQL advanced learning notes (III)
- Sourcetree details
猜你喜欢

基于OpenCV实现口罩识别

Container runtime analysis

Where is the win11 microphone test? Win11 method of testing microphone

Program analysis and Optimization - 9 appendix XLA buffer assignment

67 page overall planning and construction plan for a new smart city (download attached)

Implementation of VGA protocol based on FPGA
![[analysis of STL source code] imitation function (to be supplemented)](/img/40/a02a04a24f385a31e0484d1071ecec.jpg)
[analysis of STL source code] imitation function (to be supplemented)

Interface switching based on pyqt5 toolbar button -2

Pytorch里面多任务Loss是加起来还是分别backward?

How does win11 turn on visual control? Win11 method of turning on visual control
随机推荐
MySQL advanced learning notes (III)
Digital twin visualization solution digital twin visualization 3D platform
Difference between NVIDIA n card and amda card
开发知识点
Sourcetree details
How to apply for company email when registering in company email format?
Matlab 信号处理【问答笔记-1】
Agnosticism and practice makes perfect
In February 2022, the ranking list of domestic databases: oceanbase regained its popularity with "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Where is the win11 automatic shutdown setting? Two methods of setting automatic shutdown in win11
QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
接口自动化覆盖率统计——Jacoco使用
Pytorch里面多任务Loss是加起来还是分别backward?
95页智慧教育解决方案2022
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
Create an interactive experience of popular games, and learn about the real-time voice of paileyun unity
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
How QT exports data to PDF files (qpdfwriter User Guide)
I've been interviewed. The starting salary is 16K
PHP get real IP