QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721410#5547. Short FunctionSuhy#WA 1ms5992kbC++141.7kb2024-11-07 16:03:322024-11-07 16:03:34

Judging History

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

  • [2024-11-07 16:03:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5992kb
  • [2024-11-07 16:03:32]
  • 提交

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*n+ret2*x1+ret1*x2+x1*x2/n)%mo;
        //  cout<<"A"<<endl;
        x.second=(x1*x2%n)%mo;
        //  cout<<"A"<<endl;
        k/=2;
    }
    return ans;    
}
signed main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&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;
}

詳細信息

Test #1:

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

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: 1ms
memory: 5836kb

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: 5908kb

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: 5908kb

input:

2 100
1 2

output:

917380677 917380677 

result:

ok 2 number(s): "917380677 917380677"

Test #5:

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

input:

1 1
1

output:

1 

result:

ok 1 number(s): "1"

Test #6:

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

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:

472528588 421083764 424046257 521115109 691312906 975139031 549567013 559740297 887671724 43215552 31680581 835907186 455472309 931759712 503958056 509876164 37426721 482782101 314508367 922850625 495198204 325486146 848353580 973544226 907351474 516623637 976899450 510192346 924884083 355936939 906...

result:

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