結果

問題 No.573 a^2[i] = a[i]
ユーザー kk
提出日時 2021-03-17 15:49:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 4,123 ms
コンパイル使用メモリ 198,632 KB
実行使用メモリ 5,216 KB
最終ジャッジ日時 2023-08-09 11:48:03
合計ジャッジ時間 6,464 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,904 KB
testcase_01 AC 20 ms
4,908 KB
testcase_02 AC 19 ms
4,948 KB
testcase_03 AC 19 ms
4,924 KB
testcase_04 AC 19 ms
5,204 KB
testcase_05 AC 19 ms
4,928 KB
testcase_06 AC 19 ms
4,996 KB
testcase_07 AC 19 ms
5,092 KB
testcase_08 AC 19 ms
4,948 KB
testcase_09 AC 19 ms
4,948 KB
testcase_10 AC 19 ms
4,888 KB
testcase_11 AC 20 ms
5,092 KB
testcase_12 AC 19 ms
4,928 KB
testcase_13 AC 19 ms
5,184 KB
testcase_14 AC 20 ms
4,952 KB
testcase_15 AC 20 ms
4,956 KB
testcase_16 AC 19 ms
4,928 KB
testcase_17 AC 19 ms
4,884 KB
testcase_18 AC 19 ms
4,952 KB
testcase_19 AC 20 ms
4,908 KB
testcase_20 AC 19 ms
4,984 KB
testcase_21 AC 20 ms
5,024 KB
testcase_22 AC 19 ms
4,928 KB
testcase_23 AC 19 ms
4,884 KB
testcase_24 AC 19 ms
4,964 KB
testcase_25 AC 20 ms
4,992 KB
testcase_26 AC 19 ms
5,052 KB
testcase_27 AC 19 ms
5,008 KB
testcase_28 AC 20 ms
4,928 KB
testcase_29 AC 20 ms
4,964 KB
testcase_30 AC 20 ms
4,996 KB
testcase_31 AC 19 ms
5,216 KB
testcase_32 AC 19 ms
4,928 KB
testcase_33 AC 19 ms
4,968 KB
testcase_34 AC 19 ms
4,976 KB
testcase_35 AC 19 ms
5,092 KB
testcase_36 AC 19 ms
4,952 KB
testcase_37 AC 20 ms
4,952 KB
testcase_38 AC 20 ms
4,928 KB
testcase_39 AC 19 ms
4,928 KB
testcase_40 AC 19 ms
4,944 KB
testcase_41 AC 19 ms
5,004 KB
testcase_42 AC 19 ms
4,936 KB
testcase_43 AC 20 ms
4,952 KB
testcase_44 AC 20 ms
4,884 KB
testcase_45 AC 20 ms
4,960 KB
testcase_46 AC 29 ms
4,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;
long long f[100000+1], g[100000+1];

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

long long comb(int n, int k) {
  return f[n] * g[k] % MOD * g[n-k] % MOD;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  f[0] = g[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    f[i] = f[i-1] * i % MOD;
    g[i] = modpow(f[i], MOD-2, MOD);
  }
  
  int n;
  cin >> n;
  long long ret = 0;

  for (int i = 1; i <= n; i++) {
    ret += comb(n, i) * modpow(i, n-i, MOD) % MOD;
    ret %= MOD;
  }

  cout << ret << endl;
  
  return 0;
}
0