結果
| 問題 |
No.2235 Line Up Colored Balls
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-02-21 23:56:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 988 bytes |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 106,932 KB |
| 最終ジャッジ日時 | 2025-02-10 19:51:56 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 55 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
long long modc = 1e9+7;
long long mod_exp(long long b, long long e){
if (e > 0 && b == 0) return 0;
long long ans = 1;
b %= modc;
while (e > 0){
if ((e & 1LL)) ans = (ans * b) % modc;
e = e >> 1LL;
b = (b*b) % modc;
}
return ans;
}
int main(){
int N;
long long S=0, S2=0, ans=0;
cin >> N;
assert(N <= 100000);
vector<long long> A(N);
for (int i=0; i<N; i++){
cin >> A[i];
S += A[i];
S2 += (A[i]*A[i]) % modc;
S2 %= modc;
assert(1 <= A[i]);
}
assert(S <= 1e9);
ans = ((S*S) % modc + modc - S2) % modc;
ans = (ans * mod_exp(S, modc-2)) % modc;
ans = (ans + 1) % modc;
cout << ans << endl;
return 0;
}
srjywrdnprkt