結果

問題 No.573 a^2[i] = a[i]
ユーザー Fu_LFu_L
提出日時 2021-01-04 23:50:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 195,692 KB
実行使用メモリ 8,284 KB
最終ジャッジ日時 2024-04-23 08:36:13
合計ジャッジ時間 3,767 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
8,028 KB
testcase_01 AC 8 ms
8,160 KB
testcase_02 AC 8 ms
8,028 KB
testcase_03 AC 7 ms
8,280 KB
testcase_04 AC 6 ms
8,028 KB
testcase_05 AC 6 ms
8,032 KB
testcase_06 AC 7 ms
8,032 KB
testcase_07 AC 7 ms
8,028 KB
testcase_08 AC 8 ms
8,028 KB
testcase_09 AC 7 ms
8,024 KB
testcase_10 AC 6 ms
8,156 KB
testcase_11 AC 6 ms
8,160 KB
testcase_12 AC 7 ms
8,156 KB
testcase_13 AC 7 ms
8,032 KB
testcase_14 AC 6 ms
8,036 KB
testcase_15 AC 7 ms
8,028 KB
testcase_16 AC 7 ms
8,024 KB
testcase_17 AC 7 ms
8,160 KB
testcase_18 AC 6 ms
8,160 KB
testcase_19 AC 8 ms
8,156 KB
testcase_20 AC 6 ms
8,152 KB
testcase_21 AC 7 ms
8,156 KB
testcase_22 AC 7 ms
8,160 KB
testcase_23 AC 8 ms
8,164 KB
testcase_24 AC 7 ms
8,284 KB
testcase_25 AC 7 ms
8,152 KB
testcase_26 AC 8 ms
8,032 KB
testcase_27 AC 7 ms
8,024 KB
testcase_28 AC 8 ms
8,156 KB
testcase_29 AC 7 ms
8,284 KB
testcase_30 AC 6 ms
8,024 KB
testcase_31 AC 7 ms
8,152 KB
testcase_32 AC 7 ms
8,036 KB
testcase_33 AC 8 ms
8,156 KB
testcase_34 AC 7 ms
8,160 KB
testcase_35 AC 6 ms
8,152 KB
testcase_36 AC 6 ms
8,284 KB
testcase_37 AC 7 ms
8,152 KB
testcase_38 AC 7 ms
8,156 KB
testcase_39 AC 7 ms
8,028 KB
testcase_40 AC 8 ms
8,152 KB
testcase_41 AC 7 ms
8,284 KB
testcase_42 AC 7 ms
8,156 KB
testcase_43 AC 7 ms
8,160 KB
testcase_44 AC 7 ms
8,028 KB
testcase_45 AC 7 ms
8,156 KB
testcase_46 AC 16 ms
8,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef modint998244353 mint;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
ll modpow(ll a,ll n,ll MOD){
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}
const ll MAX=200005;
const ll MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll 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;
    }
}
ll COM(ll i,ll j){
    if(i<j) return 0;
    if(i<0||j<0) return 0;
    return fac[i]*(finv[j]*finv[i-j]%MOD)%MOD;
}
ll n;
ll ans;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n;
    COMinit();
    for(int i=1;i<=n;i++){
        ans=(ans+COM(n,i)*modpow(i,n-i,MOD))%MOD;
    }
    cout<<ans<<endl;

}
0