当前位置:网站首页>洛谷_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;
}
边栏推荐
- Difference between NVIDIA n card and amda card
- Mapper agent development
- sourcetree 详细
- Returns the size of the largest binary search subtree in a binary tree
- Pytorch里面多任务Loss是加起来还是分别backward?
- JSON数据传递参数
- "A good programmer is worth five ordinary programmers!"
- 【OJ】两个数组的交集(set、哈希映射 ...)
- Agnosticism and practice makes perfect
- Flexible combination of applications is a false proposition that has existed for 40 years
猜你喜欢
2022 latest and complete interview questions for software testing
数据集-故障诊断:西储大学轴承的各项数据以及数据说明
MATLAB signal processing [Q & a notes-1]
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
35页危化品安全管理平台解决方案2022版
Intranet penetration | teach you how to conduct intranet penetration hand in hand
Flexible combination of applications is a false proposition that has existed for 40 years
How to set automatic reply for mailbox and enterprise mailbox?
Yolox enhanced feature extraction network panet analysis
Digital twin visualization solution digital twin visualization 3D platform
随机推荐
MATLAB signal processing [Q & a notes-1]
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
Agnosticism and practice makes perfect
MySQL advanced learning notes (4)
35页危化品安全管理平台解决方案2022版
容器运行时分析
Connexion à distance de la tarte aux framboises en mode visionneur VNC
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
How to maintain the brand influence of clothing enterprises
RuntimeError: no valid convolution algorithms available in CuDNN
Interface automation coverage statistics - used by Jacobo
@How to use bindsinstance in dagger2
[analysis of STL source code] imitation function (to be supplemented)
"A good programmer is worth five ordinary programmers!"
返回二叉树中最大的二叉搜索子树的大小
Hit the industry directly! The propeller launched the industry's first model selection tool
MySQL advanced learning notes (III)
Top Devops tool chain inventory