QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290201#4621. LeapfroggeryspmAC ✓48ms5996kbC++201.7kb2023-12-24 15:57:522023-12-24 15:57:52

Judging History

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

  • [2023-12-24 15:57:52]
  • 评测
  • 测评结果:AC
  • 用时:48ms
  • 内存:5996kb
  • [2023-12-24 15:57:52]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
template<typename T>inline void ckmax(T &x,T y){x=x<y?y:x;}
template<typename T>inline void ckmin(T &x,T y){x=x>y?y:x;}
template<typename T=int>inline T read(){
    T res=0,f=1; char k;
    while(!isdigit(k=getchar())) if(k=='-') f=-1;
    while(isdigit(k)) res=res*10+k-'0',k=getchar();
    return res*f;
}
template<typename T>inline void print(T x,bool fl=1){
    if(x<0) putchar('-'),x=-x; 
    if(x>=10) print(x/10,0);
    putchar(x%10+'0');
    if(fl) putchar('\n');
}
const int mod=998244353;
inline int add(int x,int y,int Mod=mod){return x+y>=Mod?x+y-Mod:x+y;}
inline int del(int x,int y,int Mod=mod){return x-y<0?x-y+Mod:x-y;}
inline int mul(int x,int y,int Mod=mod){return x*y-x*y/Mod*Mod;}
inline void ckadd(int &x,int y,int Mod=mod){x=x+y>=Mod?x+y-Mod:x+y;}
inline void ckdel(int &x,int y,int Mod=mod){x=x-y<0?x-y+Mod:x-y;}
inline void ckmul(int &x,int y,int Mod=mod){x=x*y-x*y/Mod*Mod;}
inline int ksm(int x,int y,int Mod=mod){int res=1; for(;y;y>>=1,ckmul(x,x,Mod)) if(y&1) ckmul(res,x,Mod); return res;}
const int N=1e5+10;
int ifac[N],inv[N],fac[N];
signed main(){
    ifac[0]=ifac[1]=fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(int i=2;i<=1e5;++i){
        fac[i]=mul(fac[i-1],i);
        inv[i]=mod-mul(mod/i,inv[mod%i]);
        ifac[i]=mul(ifac[i-1],inv[i]);
    }
    int T=read();
    while(T--){
        int n=read(),m=read();
        int in=ksm(n,mod-2);
        int dfac=n;
        for(int k=2;k<=m;++k){
            int coef=mul(k,mul(in,inv[k-1]));
            ckmul(dfac,n+k-1);
            print(mul(k,del(mul(coef,mul(dfac,ifac[k])),inv[k-1])));   
        }
    }   
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 48ms
memory: 5996kb

input:

10
200 100000
123456789 98765
998244352 100000
950197492 99999
990099000 2
827463351 75229
2 99999
3 88888
4 77777
1 66666

output:

400
30450
1831600
586695614
452157489
257829310
792476646
629513487
388859340
897026359
639486180
44342766
828562018
270916706
850443683
769355291
507593164
121275944
73818483
113697879
878858854
364334497
298287562
412975054
695332112
909385381
478541382
396049651
845579097
385170289
35705940
65732...

result:

ok 807315 lines