結果
問題 | No.2235 Line Up Colored Balls |
ユーザー |
|
提出日時 | 2023-02-22 07:10:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 1,633 ms |
コンパイル使用メモリ | 168,592 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-18 01:08:11 |
合計ジャッジ時間 | 3,185 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); const int mod = 1000000007; int N; cin >> N; assert(1 <= N && N <= 100000); ll s = 0, s1 = 0; vector<ll> x(N); for(auto &v : x){ cin >> v; assert(1 <= v && v <= 1000000000); s += v; s1 += v * v; } assert(1 <= s && s <= 1000000000); auto inv = [&](ll v){ ll res = 1, d = v % mod; for(int i = 0; i < 30; i++){ if(1000000005 >> i & 1)(res *= d) %= mod; (d *= d) %= mod; } return res; }; cout << (1 + (s * s - s1) % mod * inv(s)) % mod << '\n'; }