QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#258364#5547. Short Functionhank55663#WA 1ms4288kbC++143.5kb2023-11-19 17:31:252023-11-19 17:31:25

Judging History

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

  • [2023-11-19 17:31:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4288kb
  • [2023-11-19 17:31:25]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define pdd pair<double,double>
#define pii pair<int,int>
#define pll pair<LL,LL>
#define mp make_pair
#define LL long long
#define ULL unsigned long long
#define sqr(x) ((x)*(x))
#define pi acos(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
const int mod=998244353;
LL f_pow(LL a,LL b,LL mod){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL pre[100005];
int root=3;
pll mgcd(int a, int b){
    if(b == 0) return mp(1, 0);
    else{
        LL p = a / b;
        pll q = mgcd(b, a % b);
        return make_pair(q.y, q.x - q.y * p);
    }
}

void solve(int T){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[100005];
    pre[0]=1;
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
        pre[i]=pre[i-1]*a[i]%mod;
    }
    if(k<30){
        LL tot=1ll<<k;
        LL x=tot/n,y=tot%n;
        for(int i=1;i<=n;i++){
            int l=i,r=i+y-1;
            if(l>r){
                printf("%lld ",f_pow(pre[n],x,mod));
            }
            else{
                LL a=f_pow(pre[n],x,mod);
                if(r<=n)a=a*pre[r]%mod*f_pow(pre[l-1],mod-2,mod)%mod;
                else {
                    r-=n;
                    a=a*pre[n]%mod*f_pow(pre[l-1],mod-2,mod)%mod*pre[r]%mod;
                }
                printf("%lld ",a);
            }
        }
        printf("\n");
    }
    else{
        LL y=f_pow(2,k,n);
        LL x=(f_pow(2,k,mod-1)-y+(mod-1))%(mod-1);
        LL tot;//=f_pow(pre[n],x,mod);
        {
            /*map<int,int> m;
            LL tmp=1;
            for(int i = 0;i<100000;i++){
                m[tmp]=i;
                tmp=tmp*root%mod;
            }
            LL aa=f_pow(f_pow(root,10000,mod),mod-2,mod);
            LL res=tot;
            LL ans=-1;
            for(int i = 0;i<100000;i++){
                if(m.find(tot)!=m.end()){
                    ans=i*10000+m[tot];
                    break;
                }
                tot=tot*aa%mod;
            }
            assert(ans!=-1);*/
          //  printf("%lld %lld\n",x,y);
            LL a=x,b=n;
          //  assert(f_pow(3,a,mod)==tot);
            LL gcd=__gcd(a,b);
            a/=gcd;
            b/=gcd;
            printf("%lld %lld\n",a,b);
            assert(__gcd(b,mod-1ll)==1);
            pll p=mgcd(b,mod-1);
            LL qans=(p.x%(mod-1)+mod-1)%(mod-1)*a%(mod-1);
            printf("%lld\n",qans);
            tot=f_pow(pre[n],qans,mod);
           // printf("%lld %lld\n",a,qans);
            //tot=f_pow(root,a*qans%(mod-1),mod);
           // printf("%lld\n",f_pow(2,99,mod-1));
        }
        for(int i=1;i<=n;i++){
            int l=i,r=i+y-1;
            if(l>r){
                printf("%lld ",tot);
            }
            else{
                LL a=tot;
                if(r<=n)a=a*pre[r]%mod*f_pow(pre[l-1],mod-2,mod)%mod;
                else {
                    r-=n;
                    a=a*pre[n]%mod*f_pow(pre[l-1],mod-2,mod)%mod*pre[r]%mod;
                }
                printf("%lld ",a);
            }
        }
        printf("\n");
    }
} 

int main(){
    int t=1;
     //scanf("%d",&t);
    for(int i = 1;i<=t;i++){
     //   cerr<<i<<endl;
        solve(i);
    }
}
/*
1227076727
1919786269
1261786217
1924134973
1051246577

*/

詳細信息

Test #1:

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

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

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

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

input:

2 100
1 2

output:

134217728 1
134217728
917380677 917380677 

result:

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