結果

問題 No.573 a^2[i] = a[i]
ユーザー TangentDay
提出日時 2017-10-06 22:30:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 80,784 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-11-17 01:45:25
合計ジャッジ時間 3,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0