cleverhuangxiangyu @ 2022-04-16 16:02:08
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a[400],b,c,d,e,f,g[400],n,m,h,o=0,l,t,s,p;
for(int i=1;i<=31;i++){
a[i]=100+i;
}
for(int i=1;i<=29;i++){
b=i+31;
a[b]=200+i;
}
for(int i=1;i<=31;i++){
b=i+31+29;
a[b]=300+i;
}
for(int i=1;i<=30;i++){
b=i+31+29+31;
a[b]=400+i;
}
for(int i=1;i<=31;i++){
b=i+31+29+31+30;
a[b]=500+i;
}
for(int i=1;i<=30;i++){
b=i+31+29+31+30+31;
a[b]=600+i;
}
for(int i=1;i<=31;i++){
b=i+31+29+31+30+31+30;
a[b]=700+i;
}
for(int i=1;i<=31;i++){
b=i+31+29+31+30+31+30+31;
a[b]=800+i;
}
for(int i=1;i<=30;i++){
b=i+31+29+31+30+31+30+31+31;
a[b]=900+i;
}
for(int i=1;i<=31;i++){
b=i+31+29+31+30+31+30+31+31+30;
a[b]=1000+i;
}
for(int i=1;i<=30;i++){
b=i+31+29+31+30+31+30+31+31+30+31;
a[b]=1100+i;
}
for(int i=1;i<=31;i++){
b=i+31+29+31+30+31+30+31+31+30+31+30;
a[b]=1200+i;
}
for(int i=1;i<=360;i++){
c=a[i]/1000;
d=a[i]/100%10;
e=a[i]/10%10;
f=a[i]%10;
g[i]=f*10000000+e*1000000+d*100000+c*10000+a[i];
}
cin>>n>>m;
for(int i=n-1;i<=m;i++){
for(int j=1;j<=360;j++){
if(i==g[j]){
o=o+1;
}
}
}
cout<<o;
return 0;
}
by Fleeing_loser @ 2022-04-16 16:18:29
我觉得不用开数组做
我原来写的代码
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
if(day<=31&&day>=1)
if(i*10000+month*100+day<=y) ans++;
}
if(month==4||month==6||month==9||month==11)
{
if(day<=30&&day>=1)
if(i*10000+month*100+day<=y) ans++;
}
if(month==2)
if((i%4==0&&x%100!=0)||i%400==0)
{
if(day<=29&&day>=1)
if(i*10000+month*100+day<=y) ans++;
}
else
{
if(day<=28&&day>=1)
if(i*10000+month*100+day<=y) ans++;
}
}
by cleverhuangxiangyu @ 2022-05-05 14:28:07
@真__蒟蒻
谢谢,我会采纳的