QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721423#5547. Short FunctionSuhy#WA 1ms6004kbC++141.7kb2024-11-07 16:05:232024-11-07 16:05:28

Judging History

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

  • [2024-11-07 16:05:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6004kb
  • [2024-11-07 16:05:23]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
const int maxn=1e6+100;
int a[maxn];
int p[maxn];
int n,k;
int qpow(int x,int p,int mo){
    int ans=1;
    while(p){
        if(p&1){
            ans*=x;
            ans%=mo;
        }
        x*=x;
        x%=mo;
        p/=2;
    }
    return ans;
}
int ans=1;
int tmp=1;
int ret=0;
pair<int,int> qp2(int k,int mo=mod-1){
    pair<int,int>x=make_pair(0,2);
    pair<int,int>ans=make_pair(0,1);
    while(k){
        
        if(k&1){
            int ret1=ans.first;
            int ret2=x.first;
            int x1=ans.second;
            int x2=x.second;
            ans.first=(ret1*ret2*n+ret2*x1+ret1*x2+x1*x2/n)%mo;
            ans.second=(x1*x2%n)%mo;
        }
        
        int ret1=x.first;
        int ret2=x.first;
        // cout<<"A"<<endl;
        int x1=x.second;
        int x2=x.second; 
        // cout<<"A"<<endl;
        x.first=((ret1*ret2)%mo*n%mo+ret2*x1%mo+ret1*x2%mo+x1*x2/n)%mo;
        //  cout<<"A"<<endl;
        x.second=(x1*x2%n)%mo;
        //  cout<<"A"<<endl;
        k/=2;
    }
    return ans;    
}
signed main(){
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(i==0) p[i]=a[i]%mod;
        else p[i]=(p[i-1]*a[i])%mod;
    }
    // ret=qpow(2,k,mod-1);
    // ret=(ret*qpow(n,mod-3,mod-1))%(mod-1);
    pair<int,int>tur=qp2(k);
    ans=qpow(p[n-1],tur.first,mod);
    tmp=tur.second;
    if(tmp>=1) (ans=ans*p[tmp-1])%=mod;
    printf("%lld ",ans);
    for(int i=1;i<n;i++){
        ans=(ans*qpow(a[i-1],mod-2,mod))%mod;
        ans=(ans*a[(i+tmp-1)%n])%mod;
        printf("%lld ",ans);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5936kb

input:

5 2
1 2 3 4 5

output:

24 120 60 40 30 

result:

ok 5 number(s): "24 120 60 40 30"

Test #2:

score: 0
Accepted
time: 0ms
memory: 6004kb

input:

8 3
12 5 16 14 10 6 9 2

output:

14515200 14515200 14515200 14515200 14515200 14515200 14515200 14515200 

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 5956kb

input:

6 10
3 7 8 2 9 5

output:

56347321 169041963 833775940 811788154 844769833 639990479 

result:

ok 6 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 5816kb

input:

2 100
1 2

output:

917380677 917380677 

result:

ok 2 number(s): "917380677 917380677"

Test #5:

score: 0
Accepted
time: 0ms
memory: 6004kb

input:

1 1
1

output:

1 

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 5996kb

input:

119 1000000000
179906895 883175111 831258723 617910763 41850684 952649819 667608052 992898634 871657688 261948841 858714230 452797779 698675390 39373823 268148685 762575950 789163136 676908074 134428624 583625412 549545785 415007638 564283552 596519552 575204092 884934270 632550339 21505752 66058955...

output:

463345834 269651147 99333591 202996594 81185746 733930870 856309446 841326409 292602785 580143542 308589198 298711996 221175680 658348037 420580889 120319256 383816821 82646500 28735921 599776676 230410102 631975546 482454208 48899439 461343760 744247789 901963310 658799628 907731421 649442934 62824...

result:

wrong answer 1st numbers differ - expected: '375116230', found: '463345834'