求助P1054#9本地AC提交WA
查看原帖
求助P1054#9本地AC提交WA
394167
Cure_Wing楼主2022/8/8 20:56

正如题目所说的那样。
#9:Wrong Answer.wrong answer Too short on line 1.
输入:

1-(a^8 - 1) * 1 * (a^8 +1) * 1*1*1*1*1*(1-2)-1
26
(2^10^10-(2048^9 *2)-9+6^1)^2
9999 + 9999+9999+9999-(9999 + 9999+9999+9999)+a+ 5
(a +1+5)*(a^2 +1^2+5^2-(1-2*a*1-1)+2*5*(a+1))
((a +1)-a-8-7-( 1-(8 +7))-(9999   -9990)- 3
1-2*a^1+3*a^2-4*a^3+5*a^4-a^5*(6-7*a+8*a^2 -9*a^3)
(7+8)^4-(8*8^3*7+2^3*8*7^3)
(a^8+1)^2 -2*(1 + a^8)
(a +3*(1+5))*a^2+((1+5)*2*(1+5)+(1+5)^2)*a+(1+5)^3
(6^2 - 2*6*9+9^1*9^1)^5
((6+9)^2 - 4*6*9))^5 +(6 -6)^10^10^10^10^10^10
(6^3-3*6*9*(6-9) - 9^3)^4^8 *(6^2-2*6*9+9^2)^2
9999+(9-8)*8
a^2^2^2^2-1
6^10^10 +2-1
a^2^2^2^2^2-1
6 -6 + 1 +(6 -6)^10^7
(1-a)^2+2*a^2-4*a^3+5*a^4-6*a^5+7*a^6-8*a^7+9*a^8
7*7*7*7+8*8*8*8+4*8*7*(1-1-(8*8+7*7))+6*8*7*8*7
(7 - 8)*(8 -7)*(7 -8)*(7 -8)
(a+ 1)^3+3*(a +1)^2*5+3*(a+1)*5  * 5+(a+1)^3^1
9999^9^9-9^9^9*1111^9^9-(1-a^8)*(1+a^8) +9
a-(a + 1) + 1+1+5+12-12  +6-6+a-(8 -8)
1023 + a + 5 - 1022
6 -(6-(9-(9-(8-(5+8))))) -(a -5) +a +1+5+a
9999 + 6^10^10-11*101*9 -6^2^ 5^5^2-(1 -a-1-5-1)^3
6^10^10-9^10^10 + 1

输出:

GM

代码:

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
ll n,p[1111];
constexpr ll mod=998244353;
inline ll qpow(ll a,ll b,ll mod,ll t=1){for(;b;b>>=1,a=a*a%mod)if(b&1)t=t*a%mod;return t;}
inline short simple(char c){
    if(c=='(') return -1;if(c==')') return -2;
    if(c=='+'||c=='-') return 1;
    if(c=='*'||c=='/') return 2;
    if(c=='^') return 3;
    return 0;
}
inline bool num(char c){
    return ('0'<=c&&c<='9');
}
inline void pp(char c,char d){
    cout<<simple(c)<<' '<<simple(d)<<'\n';
}
inline bool check(string s){
    int len=s.size(),cnt=0;
    if(simple(s[0])>=1&&s[0]!='-'||simple(s[len-1])>=1) return 0;
    for(int i=0;i<len;++i){
        if(!simple(s[i])&&!num(s[i])) return 0;
        if(simple(s[i])>=1&&simple(s[i-1])>=1) return 0;
        if(s[i]=='(') ++cnt;
        if(s[i]==')')
            if(cnt>0) --cnt;
            else return 0;
    }
    return !cnt;
}
inline void f(int r){
    string s="";
    ll f[555]={0},cf=0,ct=0,now=0;
    char t[555]="";
    bool flag;
    t[0]='+';
    char c;
    while(c=getchar(),c!='\n')
        if(c!=' '&&c!='\n')
            s+=c;
    ll len=s.size();
    now=flag=0;
    for(int i=0;i<len;++i){
        if(num(s[i])){
            now=(now*10+s[i]-48)%mod;flag=1;
        }else if(s[i]=='a'){
            if(flag) f[++cf]=now;
            now=114514;flag=1;
        }else if(simple(s[i])>=1){
            if((s[i-1]=='('||i==1)&&s[i]=='-') f[++cf]=-1,s[i]='*';
            if(flag) f[++cf]=now;
            now=flag=0;
            while(simple(t[ct])>=simple(s[i])){
                if(t[ct]=='+') f[cf-1]=(f[cf-1]+f[cf])%mod,f[cf]=0;
                if(t[ct]=='-') f[cf-1]=(f[cf-1]-f[cf]+mod)%mod,f[cf]=0;
                if(t[ct]=='*') f[cf-1]=f[cf-1]*f[cf]%mod,f[cf]=0;
                if(t[ct]=='/') f[cf-1]=f[cf-1]*qpow(f[cf],mod-2,mod)%mod,f[cf]=0;
                if(t[ct]=='^') f[cf-1]=qpow(f[cf-1],f[cf],mod),f[cf]=0;
                --cf;--ct;
            }
            t[++ct]=s[i];
        }else if(s[i]=='(') t[++ct]=s[i];
        else if(s[i]==')'){
            if(flag) f[++cf]=now;
            now=flag=0;
            while(t[ct]!='('){
                if(t[ct]=='+') f[cf-1]=(f[cf-1]+f[cf])%mod,f[cf]=0;
                if(t[ct]=='-') f[cf-1]=(f[cf-1]-f[cf]+mod)%mod,f[cf]=0;
                if(t[ct]=='*') f[cf-1]=f[cf-1]*f[cf]%mod,f[cf]=0;
                if(t[ct]=='/') f[cf-1]=f[cf-1]*qpow(f[cf],mod-2,mod)%mod,f[cf]=0;
                if(t[ct]=='^') f[cf-1]=qpow(f[cf-1],f[cf],mod),f[cf]=0;
                --cf;--ct;
            }
            --ct;
        }
    }
    p[r]=f[cf];
}
signed main(){
    f(0);
    scanf("%lld",&n);while(getchar()!='\n');
    for(int i=1;i<=n;++i){
        f(i);
        if(p[0]==p[i]) putchar('A'+i-1);
    }
    return 0;
}
2022/8/8 20:56
加载中...