結果

問題 No.1081 和の和
ユーザー k10ck10c
提出日時 2020-06-21 04:52:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 4,149 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 202,900 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2023-09-16 18:03:15
合計ジャッジ時間 2,803 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,108 KB
testcase_01 AC 6 ms
6,076 KB
testcase_02 AC 6 ms
6,024 KB
testcase_03 AC 6 ms
6,012 KB
testcase_04 AC 6 ms
6,272 KB
testcase_05 AC 6 ms
6,072 KB
testcase_06 AC 6 ms
6,060 KB
testcase_07 AC 6 ms
6,108 KB
testcase_08 AC 6 ms
6,112 KB
testcase_09 AC 6 ms
6,064 KB
testcase_10 AC 6 ms
6,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#define pb push_back
#define pcnt __builtin_popcountll

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#ifdef __LOCAL
#include <dump.hpp>
#define dump(...)                                                            \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
          << endl                                                            \
          << "    ",                                                         \
      dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif

struct IOInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;

  IOInit() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(IOS_PREC);
    dump(IOS_PREC);
    if(AUTOFLUSH) cout << unitbuf;
  }
} IO_INIT;

using i64 = std::int_fast64_t;
using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vvi = std::vector<vector<int>>;
using vl = std::vector<ll>;
using vp = std::vector<pii>;

constexpr int INFINT = (1 << 30) - 1;                    // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;                          // 1.15x10^18
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
constexpr ld eps = 1e-6;
constexpr ll MOD = 1000000007;
constexpr ld PI = 3.141592653589793238462643383279;
constexpr int dx4[4] = {1, 0, -1, 0};
constexpr int dy4[4] = {0, 1, 0, -1};
constexpr int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};


/* ミント */
struct mint {
  typedef long long T;
  T x;
  mint(T x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  mint& operator-=(const mint a) { if ((x += MOD-a.x) >= MOD) x -= MOD; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(T t) const {
    if (!t) return 1;
    mint a = pow(t>>1); a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

/* コンブ */
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200005);

signed main(void) {
  int N; cin >> N;
  vl a(N);
  rep(i,N) cin >> a[i];
  mint ans = 0;
  rep(i,N) {
    ans += comb(N-1,i)*a[i];
  }
  pl(ans)
  return 0;
}
0