专栏文章
题解:P2010 [NOIP2016 普及组] 回文日期
P2010题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @miql5j35
- 此快照首次捕获于
- 2025/12/04 06:35 3 个月前
- 此快照最后确认于
- 2025/12/04 06:35 3 个月前
我们先用一个数组,把每月的日数存起来。
CPPint a[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
枚举出后面的月份+日期,再把整个日期算出判断一下即可。
如果在范围内,计数器累加。
AC code
CPP#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int s,l,ans,x,res;
signed main(){
cin.tie(0),cout.tie(0);
ios::sync_with_stdio(0);
scanf("%lld%lld",&s,&l);
for(int i=1;i<=12;i++){
for(int j=1;j<=a[i];j++){
x=(j%10)*1000+(j/10)*100+(i%10)*10+i/10;
res=x*10000+i*100+j;
if(res<s||res>l){
continue;
}
ans++;
}
}
printf("%lld",ans);
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...