結果
問題 | No.2235 Line Up Colored Balls |
ユーザー |
|
提出日時 | 2023-03-03 21:26:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 2,290 ms |
コンパイル使用メモリ | 193,476 KB |
最終ジャッジ日時 | 2025-02-11 01:44:29 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define pb push_backusing ll = long long;using vi = vector <int>;const ll mod = 1e9 + 7;ll qpow(ll a, ll b) {ll r = 1, t = a;for(; b; b /= 2) {if(b & 1)r = r * t % mod;t = t * t % mod;}return r;}const int N = 1e5 + 11;int a[N];int main() {ios::sync_with_stdio(0);int n; cin >> n;for(int i = 0; i < n; i ++)cin >> a[i];int s = accumulate(a, a + n, 0);ll ans = 0;for(int i = 0; i < n; i ++) {ans += a[i] * qpow(s, mod - 2) % mod* (a[i] - 1) % mod * qpow(s - 1, mod - 2);ans %= mod;}ans = s - ans * (s - 1);ans %= mod;if(ans < 0) ans += mod;cout << ans << '\n';}