1 条题解

  • -7
    @ 2017-10-08 16:39:24

    记录详情
    Wrong Answer

    状态 耗时 内存占用

    #1 Accepted 3ms 312.0 KiB
    #2 Wrong Answer 2ms 312.0 KiB
    #3 Wrong Answer 2ms 328.0 KiB
    #4 Wrong Answer 14ms 312.0 KiB
    #5 Wrong Answer 73ms 312.0 KiB
    #6 Wrong Answer 159ms 308.0 KiB
    #7 Wrong Answer 192ms 312.0 KiB
    #8 Wrong Answer 208ms 312.0 KiB
    #9 Wrong Answer 160ms 328.0 KiB
    #10 Wrong Answer 136ms 312.0 KiB

    #include<iostream>
    using namespace std;
    
    const int n2=81,n4=1185,n6=751075,n8=72879159;
    
    bool nearly2(int i1,int i2)
    {
        return i1!=i2;
    }
    
    bool nearly4(int i1,int i2,int i3,int i4)
    {
        int aa=i1+i3,bb=i2+i4,cc=aa-bb;
        if (cc==0) return false;
        else if (cc>0) return ((i1-cc>0)||(i3-cc>=0)||(i2+cc<10)||(i4+cc<10));
        else return ((i2-cc>=0)||(i4-cc>=0)||(i1+cc<10)||(i3+cc<10));
    }
    
    bool nearly6(int i1,int i2,int i3,int i4,int i5,int i6)
    {
        int aa=i1+i3+i5,bb=i2+i4+i6,cc=aa-bb;
        if (cc==0) return false;
        else if (cc>0) return ((i1-cc>0)||(i3-cc>=0)||(i5-cc>=0)||(i2+cc<10)||(i4+cc<10)||(i6+cc<10));
        else return ((i2-cc>=0)||(i4-cc>=0)||(i6-cc>=0)||(i1+cc<10)||(i3+cc<10)||(i5+cc<10));
    }
    
    bool nearly8(int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8)
    {
        int aa=i1+i3+i5+i7,bb=i2+i4+i6+i8,cc=aa-bb;
        if (cc==0) return false;
        else if (cc>0) return ((i1-cc>0)||(i3-cc>=0)||(i5-cc>=0)||(i7-cc>=0)||(i2+cc<10)||(i4+cc<10)||(i6+cc<10)||(i8+cc<10));
        else return ((i2-cc>=0)||(i4-cc>=0)||(i6-cc>=0)||(i8-cc>=0)||(i1+cc<10)||(i3+cc<10)||(i5+cc<10)||(i7+cc<10));   
    }
    
    int f1(int x)
    {
        int i,t;
        for (i=t=1;t<=x;t*=10,i++);
        return i;
    }
    
    int f2(int x)
    {
        int t;
        for (t=1;t<=x;t*=10);
        return t;
    }
    
    int main()
    {
        int a,b,sum=0;
        cin>>a>>b;
        for (int i=a;i<=b;i++) 
        {
            if (i>9 && i<100) sum+=nearly2(i/10,i%10);
            else if (i>999 && i<10000) sum+=nearly4(i/1000,i/100%10,i/10%10,i%10);
            else if (i>99999 && i<1000000) sum+=nearly6(i/100000,i/10000%10,i/1000%10,i/100%10,i/10%10,i%10);
            else if (i>9999999 && i<10000000) sum+=nearly8(i/10000000,i/1000000%10,i/100000%10,i/10000%10,i/1000%10,i/100%10,i/10%10,i%10);
        }
        cout<<sum<<endl;
        return 0;
    }
    
    • @ 2017-10-08 20:04:46

      @jerryzheng2005: 发错地方了吧,这个是 P2025 的吧

  • 1

信息

ID
2027
难度
9
分类
(无)
标签
(无)
递交数
250
已通过
8
通过率
3%
被复制
4
上传者