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 hhztl @ 2024-08-26 18:06:36

@yunxinrui
if(d+1>n[m]){
d=0;
m++;
}
应该为d=1;


by abc20131113 @ 2024-08-26 18:17:22

谢谢大佬!
改过来了,已过


by wangxiaoyi1118 @ 2024-08-26 18:25:47

@abc20131113 蛋仔ID发下呗


by abc20131113 @ 2024-08-26 21:39:24

@wangxiaoyi1118 啥意思(我只能说我不玩蛋仔


by wangxiaoyi1118 @ 2024-08-26 22:05:57

@abc20131113 我看头像也是...


by abc20131113 @ 2024-08-26 22:20:21

@wangxiaoyi1118 是不是跑题了......


by sapo1o @ 2024-08-31 18:22:55

@wangxiaoyi1118 你在这里问那些乱七八糟没有意义的事情还不如去做几道提升你那本来就没有多少的实力。


by wangxiaoyi1118 @ 2024-08-31 21:28:11

@sapo1o 关你什么事,你何方神圣啊,我做个事情要向你请示?你管得着吗。


by wangxiaoyi1118 @ 2024-08-31 22:04:21

@sapo1o so?


by wangxiaoyi1118 @ 2024-08-31 22:05:30

@sapo1o 那你又是何方神圣啊,我做题少怎么你了


| 下一页