60分,救我!QWQ

P2010 [NOIP2016 普及组] 回文日期

abc20131113 @ 2024-08-26 18:02:09


#include<bits/stdc++.h>  
using namespace std;  
int n[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};  
int main(){  
//  freopen(".in","r",stdin);  
//  freopen(".out","w",stdout);  
    int f,t;  
    cin>>f>>t;  
    int y=f/10000;  
    int m=f%10000/100;  
    int r=f%100;  
    int sum=0;  
    //cout<<year<<" "<<month<<" "<<day<<endl;  
    while(y*10000+m*100+r<=t){  
        if(y%400==0||y%100!=0&&y%4==0){  
            n[2]=29;  
        }  
        else{  
            n[2]=28;  
        }  
        int a,b,c,d;  
        d=m/10;  
        c=m%10;  
        b=r/10;  
        a=r%10;  
        if(d+10*c+100*b+1000*a==y){   
            sum++;  
        }  
        if(d+1>n[m]){  
            d=0;  
            m++;  
        }  
        if(m>12){  
            m=1;  
            y++;  
        }  
        r++;  
    }  
    cout<<sum;  
    return 0;  
}

by PYM20111102 @ 2024-10-06 13:43:33

@DengDuck 楼上又要颠了


by abc20131113 @ 2024-10-06 18:19:47

@PYM20111102 这贴我发现除了前面两个回复有用之外,其他的好像都没用啊(无语至极的我)


by PYM20111102 @ 2024-10-06 22:00:28

@abc20131113 好像是哦!


by abc20131113 @ 2024-10-07 09:00:31

@PYM20111102 我真的无语死了 T-T


by PYM20111102 @ 2024-10-07 12:46:13

@abc20131113 是的!可是问题在第一条就解决了啊!?


by PYM20111102 @ 2024-10-07 12:47:17

@abc20131113 已关注


上一页 |