QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771906#9627. 算术clover#WA 1ms3720kbC++202.1kb2024-11-22 16:15:432024-11-22 16:15:43

Judging History

你现在查看的是最新测评结果

  • [2024-11-22 16:15:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-11-22 16:15:43]
  • 提交

answer

// dzx
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int N=1e5+5;
const int M=1e5+5,P=998244353,INF=1e18;
typedef pair<int,int> PII;
#define fi first
#define se second
int a[N],n=10,aans[105];

void pre()
{
    aans[1]=1;
    for(int i=2;i<=100;i++)
    {
        aans[i]=i;
        for(int j=1;j<=i-j;j++)
            aans[i]=max(max(aans[i],j*aans[i-j]),(i-j)*aans[j])%P;
    }

    // for(int i=1;i<=100;i++)
    // {
    //     cout<<aans[i]<<" ";
    //     if(i%10==0) cout<<endl;
    // } 
    
}

int qmi(int a,int b)
{
    int res=1;
    while(b){
        if(b&1) res=res*a%P;
        a=a*a%P;
        b>>=1;
    }
    return res;
}
 
void solve()
{
    int mi=-1,fg=0,fg1=0;
    a[10]=0;
    for(int i=1;i<=9;i++)
    {
        cin>>a[i];
        if(i==1 && a[i]) fg=1; //说明有1
        if(i!=1 && a[i] && mi==-1) mi=i;
        if(a[i]) fg1=1;
    }
    if(!fg1) //全是0
    {
        cout<<0<<endl;
        return;
    }
        
    if(fg==1 && mi==-1) //说明只有1
    {
        cout<<aans[a[1]]<<endl;
        return;
    }
 
    if(fg==0) //没有1 直接乘
    {
        int ans=1;
        for(int i=1;i<=10;i++)
        {
            ans=ans*qmi(i,a[i])%P;
        }
        cout<<ans<<endl;
        return;
    }

    if(mi!=-1)while(a[mi]<a[1]){
        if(a[1]<=mi)break;
        while(a[mi]){
            a[mi]--;
            a[mi+1]++;
            a[1]--;
        }
        mi++;
        if(a[1]<=mi)break;
    }
    a[mi]+=a[1]/mi;
    a[1]%=mi;
 
    // cout<<a[1]<<endl;
    int ans=1;
    if(a[1]==1)
    {
        a[mi]--;
        a[mi+1]++;
    }
    else if(a[1]==2)
    {
        a[2]++;
    }
    else if(a[1])
    {
        ans=aans[a[1]];
    }
 
 
    for(int i=2;i<=10;i++)
    {
        ans=ans*qmi(i,a[i])%P;       
    }
    cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    pre();
    int _T=1;
    cin>>_T;
    while(_T--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3644kb

input:

7
5 3 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0
1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 2
99 88 77 66 55 44 33 22 11
100 90 80 70 60 50 40 30 20

output:

54
108
1
10
90
90553232
143532368

result:

ok 7 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3720kb

input:

1000
22 80 50 23 35 71 81 70 96
40 33 36 2 51 52 96 5 32
56 35 85 13 58 80 26 14 31
60 21 8 19 79 5 94 44 33
85 55 10 59 76 98 28 22 69
14 72 40 14 100 68 5 18 69
95 42 51 0 32 97 37 34 85
54 33 18 40 34 10 72 72 68
81 47 80 23 23 68 40 3 71
58 7 36 79 89 83 5 68 16
30 3 82 79 35 28 30 55 88
17 86 2...

output:

5277300
321820208
765709043
672731885
639261805
42994249
7172464
780360907
240853384
815596610
298466126
589451039
124742738
510348155
677379188
877067030
409158325
951979430
342392465
777551199
440485591
163247072
78098984
640710339
308024444
168349368
371475465
252122927
827159852
914298923
465210...

result:

wrong answer 1st lines differ - expected: '376701872', found: '5277300'