結果

問題 No.1259 スイッチ
ユーザー ShibuyapShibuyap
提出日時 2020-10-28 20:34:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,526 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 199,892 KB
実行使用メモリ 46,532 KB
最終ジャッジ日時 2023-09-29 03:45:38
合計ジャッジ時間 10,443 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 49 ms
38,788 KB
testcase_04 AC 49 ms
38,692 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 48 ms
38,692 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 61 ms
42,696 KB
testcase_31 AC 65 ms
44,228 KB
testcase_32 AC 57 ms
41,100 KB
testcase_33 AC 69 ms
46,340 KB
testcase_34 AC 61 ms
42,828 KB
testcase_35 AC 64 ms
44,572 KB
testcase_36 AC 63 ms
44,268 KB
testcase_37 AC 61 ms
43,768 KB
testcase_38 AC 64 ms
43,404 KB
testcase_39 AC 70 ms
46,060 KB
testcase_40 AC 67 ms
46,064 KB
testcase_41 AC 65 ms
44,780 KB
testcase_42 AC 68 ms
46,436 KB
testcase_43 AC 64 ms
43,128 KB
testcase_44 AC 72 ms
45,964 KB
testcase_45 AC 75 ms
46,484 KB
testcase_46 AC 57 ms
42,888 KB
testcase_47 AC 67 ms
46,460 KB
testcase_48 AC 57 ms
42,384 KB
testcase_49 AC 67 ms
46,208 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define srep(i,s,t) for (ll i = s; i < t; ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

const int MAX = 1510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    COMinit();
    ll n, k, m;
    cin >> n >> k >> m;

    ll facn[n+1] = {};
    facn[0] = 1;
    srep(i,1,n+1){
        facn[i] = facn[i-1] * n % MOD;
    }

    ll ans = 0;

    if(m == 1){
        srep(i,1,n+1){
            if(k % i != 0) continue;
            ans += fac[n-1] * finv[n-i] % MOD * facn[n-i] % MOD;
            ans %= MOD;
        }
    }else{
        srep(i,1,n+1){
            if(k % i == 0) continue;
            ans += fac[n-2] * finv[n-i] % MOD * facn[n-i] % MOD;
            ans %= MOD;
        }
    }

    cout << ans << endl;
    return 0;
}
 
 
0