70分蒟蒻求助

P2010 [NOIP2016 普及组] 回文日期

Wil_ @ 2019-10-07 16:06:06

<pre>

include<bits/stdc++.h>

using namespace std; int month[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31}; int ans=0; int dz(int a,int n,int sum){ if(a==0) return sum; sum+=(a%10)*n; n/=10;a/=10; dz(a,n,sum); } int main(){ int rs; int re; cin>>rs>>re; int n1,n2; n1=rs/10000; n2=re/10000; int t=0; for(int i=n1;i<=n2;i++){ int ds=dz(i,1000,0); if(i%4==0){ month[2]++; t=1; } if((ds%10000/100)<=12&&(ds%10000/100)>=1&&(ds%100)<=month[ds%10000/100]){ if(i==n2){ if(ds<=(re%10000)){ ans++; break; }else{ break; } } if(i==n1){ if(ds>=(rs%10000)){ ans++; continue; }else{ continue; } } ans++; t=0; month[2]--; } } cout<<ans; } <code>


by Wil_ @ 2019-10-07 16:06:16

include<bits/stdc++.h>

using namespace std; int month[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31}; int ans=0; int dz(int a,int n,int sum){ if(a==0) return sum; sum+=(a%10)*n; n/=10;a/=10; dz(a,n,sum); } int main(){ int rs; int re; cin>>rs>>re; int n1,n2; n1=rs/10000; n2=re/10000; int t=0; for(int i=n1;i<=n2;i++){ int ds=dz(i,1000,0); if(i%4==0){ month[2]++; t=1; } if((ds%10000/100)<=12&&(ds%10000/100)>=1&&(ds%100)<=month[ds%10000/100]){ if(i==n2){ if(ds<=(re%10000)){ ans++; break; }else{ break; } } if(i==n1){ if(ds>=(rs%10000)){ ans++; continue; }else{ continue; } } ans++; t=0; month[2]--; } } cout<<ans; }


by Wil_ @ 2019-10-07 16:06:47

求各位大佬看一下为什么wa三个点


by Wil_ @ 2019-10-07 16:07:19

有一个点
10000101 99991231 331 输出394


by KazamiHina @ 2019-10-07 16:14:17

望丰展用MD


by __一氧化二氢__ @ 2019-10-07 16:16:37

望丰展用

MD

by yyy_o2 @ 2019-10-21 22:15:22

希丰展使

MD


by yyy_o2 @ 2019-10-21 22:19:32

#include<bits/stdc++.h>
using namespace std; int month[13]=-1,31,28,31,30,31,30,31,31,30,31,30,31};
int ans=0; 
int dz(int a,int n,int sum)
{ if(a==0) 
return sum;
sum+=(a%10)*n;
n/=10;
a/=10;
dz(a,n,sum);
}
int main()
{ int rs;
int re; 
cin>>rs>>re;
int n1,n2; 
n1=rs/10000; 
n2=re/10000; 
int t=0; 
for(int i=n1;i<=n2;i++)
{ int ds=dz(i,1000,0); 
if(i%4==0)
{ month[2]++; t=1; }
if((ds%10000/100<=12&&ds%10000/100)>=1&&(ds%100)<=month[ds%10000/100])
{ if(i==n2)
{ if(ds<=(re%10000))
{ ans++;
break; 
}
else
{ break; }
}
if(i==n1)
{ if(ds>=(rs%10000))
{ ans++; continue; 
}
else{ continue; 
} 
}
ans++;
t=0; 
month[2]--;
}
}
cout<<ans; 
}

@呵啊哈

你代码长这样吧??


by Wil_ @ 2019-10-28 13:23:09

嗯嗯


|