結果

問題 No.573 a^2[i] = a[i]
ユーザー TangentDayTangentDay
提出日時 2017-10-06 22:30:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 1,771 ms
コンパイル使用メモリ 76,264 KB
実行使用メモリ 6,756 KB
最終ジャッジ日時 2023-08-10 17:17:02
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
6,488 KB
testcase_01 AC 30 ms
6,612 KB
testcase_02 AC 30 ms
6,452 KB
testcase_03 AC 32 ms
6,512 KB
testcase_04 AC 30 ms
6,456 KB
testcase_05 AC 31 ms
6,456 KB
testcase_06 AC 30 ms
6,440 KB
testcase_07 AC 30 ms
6,444 KB
testcase_08 AC 31 ms
6,452 KB
testcase_09 AC 32 ms
6,456 KB
testcase_10 AC 31 ms
6,596 KB
testcase_11 AC 30 ms
6,632 KB
testcase_12 AC 31 ms
6,532 KB
testcase_13 AC 31 ms
6,500 KB
testcase_14 AC 31 ms
6,712 KB
testcase_15 AC 31 ms
6,612 KB
testcase_16 AC 31 ms
6,504 KB
testcase_17 AC 31 ms
6,556 KB
testcase_18 AC 30 ms
6,500 KB
testcase_19 AC 31 ms
6,512 KB
testcase_20 AC 29 ms
6,736 KB
testcase_21 AC 30 ms
6,572 KB
testcase_22 AC 31 ms
6,448 KB
testcase_23 AC 30 ms
6,496 KB
testcase_24 AC 30 ms
6,488 KB
testcase_25 AC 30 ms
6,492 KB
testcase_26 AC 30 ms
6,492 KB
testcase_27 AC 30 ms
6,596 KB
testcase_28 AC 31 ms
6,756 KB
testcase_29 AC 30 ms
6,488 KB
testcase_30 AC 31 ms
6,488 KB
testcase_31 AC 31 ms
6,628 KB
testcase_32 AC 31 ms
6,436 KB
testcase_33 AC 31 ms
6,552 KB
testcase_34 AC 29 ms
6,532 KB
testcase_35 AC 31 ms
6,548 KB
testcase_36 AC 31 ms
6,520 KB
testcase_37 AC 29 ms
6,636 KB
testcase_38 AC 30 ms
6,552 KB
testcase_39 AC 30 ms
6,536 KB
testcase_40 AC 29 ms
6,504 KB
testcase_41 AC 30 ms
6,496 KB
testcase_42 AC 31 ms
6,436 KB
testcase_43 AC 30 ms
6,448 KB
testcase_44 AC 30 ms
6,712 KB
testcase_45 AC 30 ms
6,548 KB
testcase_46 AC 40 ms
6,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


const ll mod = 1000000007;
const int N = 200010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

int main() {
    fact[0] = invf[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
        invf[i] = divll(invf[i-1], i);
    }

    ll n;
    cin >> n;

    ll ans = 0;
    FOR(i,1,n){
        ll tmp = nCr(n, i);
        tmp = (tmp * powll(i,n-i)) % mod;
        ans = (ans + tmp) % mod;
    }
    cout << ans << endl;


    return 0;
}
0