PC

P1055 [NOIP2008 普及组] ISBN 号码

csf02vv03 @ 2024-06-28 20:24:30

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,b1,b2,b3,c,c1,c2,c3,c4,c5,d,e;
int main(){
    ios::sync_with_stdio;
    cin.tie(0);
    cin>>a>>b>>c>>d;
    if(a<0)a-=2*a;
    if(b<0)b-=2*b;
    if(c<0)c-=2*c;
    if(d<0)d-=2*d;
    b1=b/100;
    b2=b/10-10*b1;
    b3=b-100*b1-10*b2;
    c1=c/10000;
    c2=c/1000-10*c1;
    c3=c/100-100*c1-10*c2;
    c4=c/10-1000*c1-100*c2-10*c3;
    c5=c-10000*c1-1000*c2-100*c3-10*c4;
    if((a+2*b1+3*b2+4*b3+5*c1+6*c2+7*c3+8*c4+9*c5)%11==d)cout<<"Right";
    else{
        e=(a+2*b1+3*b2+4*b3+5*c1+6*c2+7*c3+8*c4+9*c5)%11;
        if(e==10)cout<<a<<"-"<<b<<"-"<<c<<"-"<<"X";
        else cout<<a<<"-"<<b<<"-"<<c<<"-"<<e;
    }
    return 0;
}

AC #1#2#3#5#6#8#9#10

WA #4#7


by csf02vv03 @ 2024-06-28 20:47:48

求调


|