結果
| 問題 |
No.573 a^2[i] = a[i]
|
| コンテスト | |
| ユーザー |
0x19f
|
| 提出日時 | 2017-10-07 02:17:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 733 bytes |
| コンパイル時間 | 1,312 ms |
| コンパイル使用メモリ | 160,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 03:18:22 |
| 合計ジャッジ時間 | 3,655 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
ll N;
ll fact[100001], ifact[100001];
ll modulo_power(ll a, ll n) {
if(n == 0) return 1;
if(n % 2 == 0) return modulo_power((a * a) % MOD, n / 2);
return (a * modulo_power(a, n - 1)) % MOD;
}
ll combination(ll n, ll r) {
return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}
int main(void) {
cin >> N;
fact[0] = 1;
REP(i, 1, 100001) fact[i] = fact[i - 1] * i % MOD;
REP(i, 0, 100001) ifact[i] = modulo_power(fact[i], MOD - 2);
ll ans = 0;
REP(i, 1, N + 1) ans = (ans + combination(N, i) * modulo_power(i, N - i) % MOD) % MOD;
cout << ans << endl;
}
0x19f