結果

問題 No.2120 場合の数の下8桁
ユーザー roarisroaris
提出日時 2022-11-04 22:01:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,376 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 203,024 KB
実行使用メモリ 81,244 KB
最終ジャッジ日時 2023-09-26 00:26:09
合計ジャッジ時間 7,256 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
81,244 KB
testcase_01 AC 238 ms
81,004 KB
testcase_02 AC 231 ms
81,188 KB
testcase_03 AC 231 ms
81,084 KB
testcase_04 AC 229 ms
81,008 KB
testcase_05 AC 239 ms
80,900 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const ll MOD = 100000000;

struct Fast_factorize {
    vector<int> p;
    
    Fast_factorize(int n) {
        p.resize(n+1);
        fill(p.begin(), p.end(), -1);
        for (int i=2; i<=n; i++) if (p[i]==-1) {
            for (int j=i; j<=n; j+=i) {
                if (p[j]==-1) p[j] = i;
            }
        }
    }
    
    vector<int> factorize(int n) {
        vector<int> res;
        while (n>1) {
            res.pb(p[n]);
            n /= p[n];
        }
        return res;
    }
};

ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n>0) {
        if (n&1) res = res*x%MOD;
        x = x*x%MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    Fast_factorize ff(10000010);
    
    int M, N; cin >> M >> N;
    
    int cnt[10000010];
    fill(cnt, cnt+10000010, 0);
    
    for (int i=M; i>=M-N+1; i--) {
        for (int p : ff.factorize(i)) cnt[p]++;
    }
    
    for (int i=1; i<=N; i++) {
        for (int p : ff.factorize(i)) cnt[p]--;
    }
    
    ll ans = 1;
    rep(i, 10000010) {
        ans *= mod_pow(i, cnt[i]);
        ans %= MOD;
    }
    
    string s = to_string(ans);
    if (s.size()<8) s = string(8-s.size(), '0')+s;
    cout << s << endl;
}
0