結果
問題 |
No.2235 Line Up Colored Balls
|
ユーザー |
![]() |
提出日時 | 2023-03-07 02:43:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 506 bytes |
コンパイル時間 | 4,210 ms |
コンパイル使用メモリ | 251,596 KB |
最終ジャッジ日時 | 2025-02-11 06:04:21 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.14159265359; ll inf=10000000000000001; ll mod=1000000007; int main(){ ll n; cin >> n; vector<ll>x(n); ll sum=0; for (ll i = 0; i < n; i++) { cin >> x[i]; sum+=x[i]; } ll ans=0; for (ll i = 0; i < n; i++) { ll y=sum-x[i]; y*=x[i]; y%=mod; ans+=y; ans%=mod; } ans*=inv_mod(sum,mod); ans+=1; ans%=mod; ans%=mod; cout << ans << endl; }