Educational Codeforces Round 88 (Rated for Div. 2) E - Modular Stability

東扯西扯,發現了個性質,就是恰好選的元素裏面都是最小數的倍數時,這個肯定成立。
原因:因爲我們變換取模,最後對最小值取模之後,這個值就固定了,那麼隨意換順序取模,能和mod 最小值一樣的,這個序列就成立,所以其它數必然是最小值的倍數,對其他數取模的時候就相當於減去x被最小值。

code

#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 5e5+10;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
const ll mod = 998244353;
bool vis[man];

ll quick_mod(int a,int b){
    ll ans = 1;
    while(b){
        if(b&1)ans = ans * a % mod;
        a =1ll * a * a % mod;
        b >>= 1;
    }
    return ans;
}

inline ll C(int n,int k){
    if(n<k)return 0;
    if(n==k||k==0)return 1;
    if(n-k<k)k = n - k;
    ll res1 = 1,res2 = 1;
    for(int i = k;i;--i){
        res1 = res1 * (n - i + 1) % mod;
        res2 = res2 * i % mod;
    }
    return res1 * quick_mod(res2,mod-2) % mod;
}

int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int n,k;
    scanf("%d%d",&n,&k);
    ll ans = 0;
    For(i,1,n){
        int cnt = n / i;
        ans = (ans + C(cnt-1,k-1))% mod;
    }
    cout << ans << endl;
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章