求大佬!

P2010 [NOIP2016 普及组] 回文日期

御·Dragon @ 2018-06-19 20:25:34

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int hw(ll a){
    int o=a,p;
    string x;
    while(o>0){
        o/=10;
        p++;
    }
    o=a;
    while(o>0){
        x[p]=(o%10)+'0';
        o/=10;p--;
    }
    for(int i=1;i<=x.size()/2;i++){
        if(x[i]!=x[x.size()-i+1]){
            return 0;
        }
    }
    return 1;
}
ll n,m,i,ans;
int main()
{
    cin>>n>>m;
    for(i=n;i<=m;i++){
        if(hw(i))ans++;
    }
    cout<<ans;
    return 0;
}

全RE!


by Papaya @ 2018-06-19 20:47:17

请问您怎么循环的?? 您家里的日历是这样走的吗?


by jinhangjie2006 @ 2018-08-07 09:43:51

var a:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31); s1,s2,i,j,t,ans:longint; begin readln(s1); readln(s2); for i:=1 to 12 do for j:=1 to a[i] do begin t:=j mod 1010000000+j div 101000000+i mod 10100000+i div 1010000+i div 101000+i mod 10100+j div 10*10+j mod 10; if (t>=s1) and (t<=s2) then inc(ans); end; writeln(ans); end.


by jinhangjie2006 @ 2018-08-07 09:46:01

var a:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31); s1,s2,i,j,t,ans:longint; begin readln(s1); readln(s2); for i:=1 to 12 do for j:=1 to a[i] do begin t:=j mod 1010000000+j div 101000000+i mod 10100000+i div 1010000+i div 101000+i mod 10100+j div 10*10+j mod 10; if (t>=s1) and (t<=s2) then inc(ans); end; writeln(ans); end.//Pascal题解 简单AC 哈哈 更具日期和月份 硬性规定他是个回文数 再看看他是不是在范围内 整个程序重在于1句话


|