結果
問題 | No.2235 Line Up Colored Balls |
ユーザー |
|
提出日時 | 2023-03-03 23:00:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 689 ms |
コンパイル使用メモリ | 85,020 KB |
最終ジャッジ日時 | 2025-02-11 04:10:44 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:38:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d", &xs[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <map> #include <vector> #include <queue> #include <deque> #include <set> #include <stack> #include <algorithm> #include <array> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; #define MOD 1000000007 int xs[100004]; int expit(LL b, LL e) { LL r=1; while(e) { if (e&1) { r*=b; r%=MOD; } b*=b; b%=MOD; e>>=1; } return r; } int main() { int n, i; LL s=0, r=0, t1, t2, t, c; scanf("%d", &n); for (i=0; i<n; i++) { scanf("%d", &xs[i]); s+=xs[i]; } for (i=0; i<n; i++) { c=xs[i]; r+=1; r%=MOD; // // t = 1-(1-1/(c+1))**(s-c) t1 = c;// expit(c, s-c); // t2 = expit(c+1, s-c); t2 = expit(s, MOD-2); t1*=t2; t1%=MOD; t = 1-t1; if (t<0) t+=MOD; t*=(c-1); t%=MOD; r+=t; r%=MOD; } printf("%lld\n", r); return 0; }