90wa?!

P2010 [NOIP2016 普及组] 回文日期

WELTh1113 @ 2024-10-01 22:41:32

90分*wa第九个点

求大佬帮忙

#include <bits/stdc++.h>
using namespace std;
#define long long int 
int d1, d2;
int cnt = 0;
int tc[105] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int tr[105] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int ry(int year) {
    if( (year%4 == 0 && year%100 != 0) || year%400 != 0) return 1;
    return 0;

}

void pd(int k) {
    int month=(k%10)*10+(k%100)/10;
    int day=((k/100)%10)*10 + k/1000;
    if( ry(k) ) {
        if(month >= 1 && month <= 12 && day >= 1 && day <= tr[month]) cnt++;
    } else {
        if(month >= 1 && month <= 12 && day >= 1 && day <= tc[month]) cnt++;
    }
}

int main() {
//  cout << pd(2002) return 0;
    cin >> d1 >> d2;

    int sy = d1/10000;
    int sm = (d1%10000)/100;
    int sd = d1-sy*10000-sm*100;

    int ey = d2/10000;
    int em = (d2%10000)/100;
    int ed = d2-ey*10000-em*100;

    int aam=(sy%10)*10+(sy%100)/10;
    int aad=((sy/100)%10)*10 + sy/1000;

//  cout<<sy<<" " << sm << " " << sd << endl;
//  cout << ((sy/100)%10)*10<<endl;
//  cout<<aam <<" " << aad << " ";

    if(sy != ey) {
        if( ry(sy) ) {
            if(aam>=1 && aam<=12 && aam>=sm && aad>=1 && aad<=tr[aam] && aad>=sd) cnt++;
        } else{
            if(aam>=1 && aam<=12 && aam>=sm && aad>=1 && aad<=tc[aam] && aad>=sd) cnt++;
        }

        int bbm=(ey%10)*10+(ey%100)/10;
        int bbd=((ey/100)%10)*10 + ey/1000;

        if( ry(ey) ) {
            if(bbm>=1 && bbm<=12 && bbm<=em && bbd>=1 && bbd<=tr[bbm] && bbd<=ed) cnt++;
        } else{
            if(bbm>=1 && bbm<=12 && bbm<=em && bbd>=1 && bbd<=tc[bbm] && bbd<=ed) cnt++;
        }
    } else{
        if(em > aam || (em >= aam && ed >= aad))
            if( ry(sy) ) {
                if(aam>=1 && aam<=12 && aam>=sm && aad>=1 && aad<=tr[aam] && aad>=sd) cnt++;
            } else{
                if(aam>=1 && aam<=12 && aam>=sm && aad>=1 && aad<=tc[aam] && aad>=sd) cnt++;
            }
    }

    for(int i = sy+1; i < ey; i++) {
        pd(i);
    }

    cout << cnt << endl;

    return 0;
} 

by KaMuaMua @ 2024-10-05 11:50:42

#include<bits/stdc++.h>
using namespace std;
int m,n,z,c,i,j,k,l;
int main(){
    cin>>m>>n;
    for(i=0;i<=m;i++)
        for(j=0;j<=n;j++)
            for(k=i+1;k<=m;k++)
                for(l=j+1;l<=n;l++)
                    if(k-i==l-j)z++;
                    else c++;
    cout<<z<<" "<<c;
}

借你用用


|