結果
| 問題 |
No.2235 Line Up Colored Balls
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2023-03-04 02:41:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 640 bytes |
| コンパイル時間 | 1,591 ms |
| コンパイル使用メモリ | 169,836 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 01:14:21 |
| 合計ジャッジ時間 | 6,240 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 55 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll mod=1e9+7;
ll mod_pow(ll x,ll n,ll mod) {
ll res=1;
while(n>0) {
if(n&1) {
res=res*x%mod;
}
x=x*x%mod;
n>>=1;
}
return res;
}
int main() {
ll N;cin>>N;
vector<ll> x(N);
ll s=0;
for(ll i=0;i<N;i++) {
cin>>x[i];
s+=x[i];
}
ll ans=0;
for(ll i=0;i<N;i++) {
ans+=(s-x[i])*x[i]%mod*mod_pow(s,mod-2,mod)%mod;
ans%=mod;
}
ans++;
ans%=mod;
cout<<ans<<endl;
}
planes