結果

問題 No.2235 Line Up Colored Balls
ユーザー no way
提出日時 2023-03-03 22:03:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 165,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 01:11:59
合計ジャッジ時間 3,742 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,x;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1ll*x*x%mod) if (y&1) ans=1ll*ans*x%mod;
	return ans;
}
int main(){
	scanf("%d",&n);
	int s=0,s1=0;
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		s=s+x;
		s1=(s1+1ll*x*(x-1)%mod)%mod;
	}
	printf("%d\n",(s-1ll*s1*ksm(s,mod-2)%mod+mod)%mod);
}
0