QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768881#9553. The HermitAiriS#RE 13ms10368kbC++14991b2024-11-21 15:02:142024-11-21 15:02:21

Judging History

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

  • [2024-11-21 15:02:21]
  • 评测
  • 测评结果:RE
  • 用时:13ms
  • 内存:10368kb
  • [2024-11-21 15:02:14]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define int long long
int n,m;

const int N=110000,P=998244353;
int quickpow(int a,int b){
    int ans=1,base=a;
    while(b){
        if(b&1)(ans*=base)%=P;
        (base*=base)%=P;
        b>>=1;
    }
    return ans;
}
int jc[N],inv[N];
void pre(int n){
    jc[0]=1;
    for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%P;
    for(int i=0;i<=n;i++)inv[i]=quickpow(jc[i],P-2);
}
int C(int a,int b){
    if(a<b)return 0;
    return jc[a]*inv[b]%P*inv[a-b]%P;
}
map<int,int> F[N];
int f(int n,int m){
    if(n>=m)return 0;
    if(F[n][m])return F[n][m];
    int ans=C(m-1,n)*n%P;
    for(int l=2,r;l<=m;l=r+1){
        r=m/(m/l);
        (ans+=(r-l+1)*f(n-1,m/l)%P-(r-l+1)*C(m/l-1,n-1)%P*n%P)%=P;
    }
    //cerr<<n<<' '<<m<<' '<<ans<<'\n';
    return F[n][m]=(ans+P)%P;
}
signed main(){
    int n,m;cin>>m>>n;pre(m);
    cout<<(f(n,m)+f(n-1,m))%P;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 2ms
memory: 9944kb

input:

11 4

output:

1187

result:

ok 1 number(s): "1187"

Test #3:

score: 0
Accepted
time: 13ms
memory: 10348kb

input:

100000 99999

output:

17356471

result:

ok 1 number(s): "17356471"

Test #4:

score: 0
Accepted
time: 2ms
memory: 9824kb

input:

11451 1919

output:

845616153

result:

ok 1 number(s): "845616153"

Test #5:

score: 0
Accepted
time: 10ms
memory: 10368kb

input:

99998 12345

output:

936396560

result:

ok 1 number(s): "936396560"

Test #6:

score: -100
Runtime Error

input:

100000 1

output:


result: