結果

問題 No.573 a^2[i] = a[i]
ユーザー teketeke5000teketeke5000
提出日時 2017-10-10 21:17:43
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 846 bytes
コンパイル時間 1,143 ms
コンパイル使用メモリ 159,576 KB
実行使用メモリ 185,628 KB
最終ジャッジ日時 2024-04-28 15:29:17
合計ジャッジ時間 9,126 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
7,508 KB
testcase_23 AC 2 ms
7,564 KB
testcase_24 AC 2 ms
9,640 KB
testcase_25 AC 3 ms
9,620 KB
testcase_26 AC 3 ms
9,624 KB
testcase_27 AC 2 ms
9,636 KB
testcase_28 AC 3 ms
11,484 KB
testcase_29 AC 3 ms
11,644 KB
testcase_30 AC 2 ms
11,668 KB
testcase_31 AC 3 ms
13,660 KB
testcase_32 AC 5 ms
21,864 KB
testcase_33 AC 11 ms
42,512 KB
testcase_34 AC 19 ms
62,880 KB
testcase_35 AC 20 ms
68,988 KB
testcase_36 AC 22 ms
73,056 KB
testcase_37 AC 25 ms
74,216 KB
testcase_38 AC 25 ms
74,088 KB
testcase_39 AC 39 ms
79,648 KB
testcase_40 AC 48 ms
83,996 KB
testcase_41 AC 78 ms
89,768 KB
testcase_42 AC 154 ms
115,304 KB
testcase_43 AC 160 ms
115,220 KB
testcase_44 AC 465 ms
185,628 KB
testcase_45 TLE -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,a,n) for(ll i=(a); i<(ll)(n); i++)

ll MOD = 1e9 + 7;

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

//vector< vector <ll> > cm(100001, vector<ll>(100001, 0));
ll cm[10000][10000];

ll comb(ll n, ll r) {
    cm[n][r] = ( cm[n-1][r-1] ? cm[n-1][r-1] : comb(n-1, r-1) ) + ( cm[n-1][r] ? cm[n-1][r] : comb(n-1, r) );
    return cm[n][r] % MOD;
}


int main(void) {
    ll N;
    cin >> N;
    ll ans = 0;
    REP(i, 0, N+1) {
        cm[i][0] = 1;
        cm[i][i] = 1;
    }
    REP(x, 1, N) {
        //cout << comb(N, x) << endl;
        ans = (ans + ( comb(N, x) * pow_mod(x, N - x)) ) % MOD;
    }
    cout << ++ans << endl;
    return 0;
}
0