QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721433#5547. Short FunctioninfCraft#WA 1ms5668kbC++171.1kb2024-11-07 16:06:012024-11-07 16:06:04

Judging History

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

  • [2024-11-07 16:06:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5668kb
  • [2024-11-07 16:06:01]
  • 提交

answer

#include<bits/stdc++.h>
#define dbg(x) for(int i=1;i<=n;++i)std::cout<<(x[i])<<" \n"[i==n]
#define i64 long long
const int N=1e5+7;
const int P=998244353;
i64 pow(i64 a,i64 b){
    i64 ret=1;
    for(;b;b>>=1){
        if(b&1)ret=(ret*a)%P;
        a=(a*a)%P;
    }
    return ret%P;
}
i64 a[N],b[N],invb[N],inva[N];
i64 query(int x,int y){
    return b[y]*invb[x-1]%P;
}
signed main(){
    std::cin.tie(0)->sync_with_stdio(0);
    int n;std::cin>>n;
    i64 k;std::cin>>k;
    b[0]=1;
    for(int i=1;i<=n;++i){
        std::cin>>a[i];
        b[i]=a[i]*b[i-1]%P;
        invb[i]=pow(b[i],P-2);
        inva[i]=pow(a[i],P-2);
    }
    // dbg(b);
    // dbg(inva);
    i64 t=pow(2,k);
    // std::cout<<t<<'\n';
    i64 now=pow(b[n],t/n);
    // std::cout<<b[n]<<'\n';
    if(now==0)now=1;
    // std::cout<<now<<'\n';
    t=t%n;
    now=now*b[t]%P;
    // std::cout<<now<<'\n';
    // now=56347321;
    // now=917380677;
    // std::cout<<now<<'\n';
    i64 last=1;
    for(int i=1;i<=n;++i){
        std::cout<<now<<' ';
        t=t%n+1;
        now=now*inva[i]%P*a[t]%P;
        // std::cout<<a[i]<<' '<<a[t]<<'\n';
    }
}

詳細信息

Test #1:

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

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

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: 0ms
memory: 3628kb

input:

6 10
3 7 8 2 9 5

output:

56347321 169041963 833775940 811788154 844769833 639990479 

result:

ok 6 numbers

Test #4:

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

input:

2 100
1 2

output:

152295411 152295411 

result:

wrong answer 1st numbers differ - expected: '917380677', found: '152295411'