当前位置:网站首页>洛谷_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;
}边栏推荐
- RuntimeError: no valid convolution algorithms available in CuDNN
- yolov5train. py
- Intranet penetration | teach you how to conduct intranet penetration hand in hand
- Mapper agent development
- 開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
- How to set automatic reply for mailbox and enterprise mailbox?
- MATLAB signal processing [Q & a notes-1]
- VIM interval deletion note
- Codeforces Round #771 (Div. 2)---A-D
- Yolox enhanced feature extraction network panet analysis
猜你喜欢

实用系列丨免费可商用视频素材库

Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track

Optimization of streaming media technology

What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
![[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)](/img/c5/2f65d37682607aab98443d7f1ba775.jpg)
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)

Container runtime analysis

Use redis to realize self increment serial number

Maybe you read a fake Tianlong eight

Hit the industry directly! The propeller launched the industry's first model selection tool

流媒体技术优化
随机推荐
95 pages of smart education solutions 2022
What experience is there only one test in the company? Listen to what they say
Solution: exceptiole 'xxxxx QRTZ_ Locks' doesn't exist and MySQL's my CNF file append lower_ case_ table_ Error message after names startup
MFC 获取当前时间
Data set - fault diagnosis: various data and data description of bearings of Western Reserve University
RuntimeError: no valid convolution algorithms available in CuDNN
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
How does win11 turn on visual control? Win11 method of turning on visual control
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
Integration of revolution and batch normalization
MySQL Foundation
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
Difference between NVIDIA n card and amda card
JDBC教程
Sourcetree details
35 pages dangerous chemicals safety management platform solution 2022 Edition
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
Top Devops tool chain inventory
Writing of head and bottom components of non routing components
C MVC creates a view to get rid of the influence of layout