第9个点wa 跪求测试数据aaaa

P2010 [NOIP2016 普及组] 回文日期

zhouqi_97 @ 2022-04-16 10:20:12

#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,k,m,n,a,b,mi,ni,c,x,y,z,q;
    string s,st;
    cin>>s;
    cin>>st;
    m=0;
    n=0;
    z=0;
    q=0;
    c=0;
    for(i=3;i>=0;i--){
        m=m*10;
        n=n*10;
        m=m+s[i]-48;
        n=n+st[i]-48;
    }
    //cout<<m<<" "<<n<<endl;
    mi=m/1000+(m/100)%10*10+(m%100)/10*100+m%10*1000;
    ni=n/1000+(n/100)%10*10+(n%100)/10*100+n%10*1000;
    //cout<<mi<<" "<<ni<<endl;
    for(i=4;i<=7;i++){
        a=a*10;
        b=b*10;
        a=a+s[i]-48;
        b=b+st[i]-48;
    }
    //cout<<a<<" "<<b<<endl;
    for(i=mi;i<=ni;i++){
        k=i/1000+(i/100)%10*10+(i%100)/10*100+i%10*1000;
        x=k/100;
        y=k%100;
        //cout<<x<<"  "<<y<<endl;
        if(x>0&&x<=12){
            if(x==2){
                if(i%4==0){
                    if(y>0&&y<=29)c++;
                    if(i==mi)z++;
                    if(i==ni)q++;
                }
                else{
                    if(y>0&&y<=28)c++;
                    if(i==mi)z++;
                    if(i==ni)q++; 
                }
            }
            else{
                if(x<=7&&x%2==1||x>=8&&x%2==0){
                    if(y>0&&y<=31)c++;
                    if(i==mi)z++;
                    if(i==ni)q++; 
                }
                else{
                    if(y>0&&y<=30)c++;
                    if(i==mi)z++;
                    if(i==ni)q++; 
                }
            }
        }
    }
    if(z!=0){
        if(m<a)c--;
    }
    if(q!=0){
        if(n>b)c--;
    }
    cout<<c;
}

by mc_sdx @ 2022-05-06 21:54:33

IN

40110123
98900301

OUT

214

助人为乐


by Lonerwcq @ 2022-10-07 13:12:43

@mc_sdx 感谢,我也是第九个点QAQ


|