結果
問題 | No.1081 和の和 |
ユーザー | noisy_noimin |
提出日時 | 2020-06-19 21:24:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,599 bytes |
コンパイル時間 | 996 ms |
コンパイル使用メモリ | 117,812 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-16 13:12:07 |
合計ジャッジ時間 | 1,692 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <string> #include <stack> #include <queue> #include <map> #include <set> #include <tuple> #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cassert> #include <cstdint> #include <cctype> #include <numeric> #include <bitset> #include <functional> using namespace std; using ll = long long; using Pll = pair<ll, ll>; using Pii = pair<int, int>; constexpr int INF = 1 << 30; constexpr ll LINF = 1LL << 60; constexpr ll MOD = 1000000007; constexpr long double EPS = 1e-10; constexpr int dyx[4][2] = { { 0, 1}, {-1, 0}, {0,-1}, {1, 0} }; constexpr int N_MAX = 100; ll fact[N_MAX+1], rfact[N_MAX+1]; ll perm(ll n, ll k) { if(n-k < 0LL) return 0LL; return (fact[n] * rfact[n-k]) % MOD; } ll comb(ll n, ll k) { if(n-k < 0LL) return 0LL; return (perm(n, k) * rfact[k]) % MOD; } ll modpow(ll a, ll p) { ll ret = 1LL; while(p) { if(p & 1) { ret = (ret * a) % MOD; } a = (a * a) % MOD; p >>= 1; } return ret; } void init_fact(ll n) { fact[0] = fact[1] = 1; rfact[0] = rfact[1] = 1; for(ll i=2;i<=n;++i) { fact[i] = (fact[i-1] * i) % MOD; rfact[i] = modpow(fact[i], MOD-2); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; init_fact(n+1); vector<ll> a(n); ll ans = 0LL; for(int i=0;i<n;++i) { cin >> a[i]; ans += (a[i] * comb(n-1, i)) % MOD; ans %= MOD; } cout << ans << endl; }