当前位置:网站首页>洛谷_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;
}边栏推荐
- yolov5detect. Py comment
- Convolution和Batch normalization的融合
- How much do you know about synchronized?
- Dishes launcher small green program and directory management (efficiency tool)
- What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
- Digital twin visualization solution digital twin visualization 3D platform
- How much do you know about synchronized?
- 附加:token;(没写完,别看…)
- 采用VNC Viewer方式遠程連接樹莓派
- JDBC教程
猜你喜欢

Where is the win11 automatic shutdown setting? Two methods of setting automatic shutdown in win11

基于OpenCV实现口罩识别

JSON data transfer parameters

List of major chip Enterprises

Wechat applet basic learning (wxss)

JSON数据传递参数

Interface difference test - diffy tool

Go basic data type

QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
![[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)](/img/93/dc940caebe176177e4323317ebf4fa.jpg)
[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
随机推荐
JDBC Exercise case
@How to use bindsinstance in dagger2
yolov5detect. Py comment
How to apply for company email when registering in company email format?
JDBC tutorial
MATLAB signal processing [Q & a notes-1]
【OJ】两个数组的交集(set、哈希映射 ...)
How does win11 turn on visual control? Win11 method of turning on visual control
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
Speech recognition Series 1: speech recognition overview
Maybe you read a fake Tianlong eight
Where is the win11 microphone test? Win11 method of testing microphone
[array] binary search
Top Devops tool chain inventory
Three solutions to frequent sticking and no response of explorer in win11 system
SharedPreferences save list < bean > to local and solve com google. gson. internal. Linkedtreemap cannot be cast to exception
Use redis to realize self increment serial number
Digital twin visualization solution digital twin visualization 3D platform
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
Interface automation coverage statistics - used by Jacobo