E. Modular Stability

鏈接:https://codeforces.ml/contest/1359/problem/E

We define xmodyxmody as the remainder of division of xx by yy (%% operator in C++ or Java, mod operator in Pascal).

Let's call an array of positive integers [a1,a2,…,ak][a1,a2,…,ak] stable if for every permutation pp of integers from 11 to kk, and for every non-negative integer xx, the following condition is met:

(((xmoda1)moda2)…modak−1)modak=(((xmodap1)modap2)…modapk−1)modapk(((xmoda1)moda2)…modak−1)modak=(((xmodap1)modap2)…modapk−1)modapk

That is, for each non-negative integer xx, the value of (((xmoda1)moda2)…modak−1)modak(((xmoda1)moda2)…modak−1)modak does not change if we reorder the elements of the array aa.

For two given integers nn and kk, calculate the number of stable arrays [a1,a2,…,ak][a1,a2,…,ak] such that 1≤a1<a2<⋯<ak≤n1≤a1<a2<⋯<ak≤n.

Input

The only line contains two integers nn and kk (1≤n,k≤5⋅1051≤n,k≤5⋅105).

Output

Print one integer — the number of stable arrays [a1,a2,…,ak][a1,a2,…,ak] such that 1≤a1<a2<⋯<ak≤n1≤a1<a2<⋯<ak≤n. Since the answer may be large, print it modulo 998244353998244353.

Examples

input

Copy

7 3

output

Copy

16

input

Copy

3 7

output

Copy

0

input

Copy

1337 42

output

Copy

95147305

input

Copy

1 1

output

Copy

1

input

Copy

500000 1

output

Copy

500000

代碼:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lb long double
#define INF 0x3f3f3f3f
#define maxn 200010
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define gep(i,x,y) for(int i=x;i>=y;i--)
ll n,T,m,h,k,t,x,y,max1,s,mod=998244353;
ll a[100001];
ll b[100001];
ll c[100001];
ll dp[100001];
const int N = 500000 + 5;
const int MOD = 998244353;
int F[N], Finv[N], inv[N];//F�ǽ׳ˣ�Finv����Ԫ�Ľ׳� 
void init(){
    inv[1] = 1;
    for(int i = 2; i < N; i ++){
        inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
    }
    F[0] = Finv[0] = 1;
    for(int i = 1; i < N; i ++){
        F[i] = F[i-1] * 1ll * i % MOD;
        Finv[i] = Finv[i-1] * 1ll * inv[i] % MOD;
    }
}
int comb(int n, int m){
    if(m < 0 || m > n) return 0;
    return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
}
int main()
{
	cin>>n>>k;
	if(k>n)
	{
		cout<<0<<endl;
	}
	else
	{
		init();
		for(int i=1;i<=n;i++)
		{
			t=floor(n*1.0/i);
			if(t>=k)
			{
				m=comb(t-1,k-1);
				s+=m;
				s%=mod;
			}
			else
			{
				break;
			}
		}
		cout<<s<<endl;
	}
}
	
		

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章