結果
| 問題 | No.766 金魚すくい |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-14 14:36:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,070 bytes |
| 記録 | |
| コンパイル時間 | 1,012 ms |
| コンパイル使用メモリ | 78,444 KB |
| 実行使用メモリ | 161,152 KB |
| 最終ジャッジ日時 | 2024-09-25 05:02:58 |
| 合計ジャッジ時間 | 15,244 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 31 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
combination table(1e7);
#define int __int128_t
#define long __int128_t
ostream &operator<<(ostream &os, __int128_t value) {
if (ostream::sentry(os)) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[64];
char *d = end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = end(buffer) - d;
if (os.rdbuf()->sputn(d, len) != len) {
os.setstate(ios_base::badbit);
}
}
return os;
}
istream &operator>>(istream &is, __int128_t &value) {
string in;
is >> in;
value = 0;
for (const char &c : in) {
if ('0' <= c && c <= '9') value = 10 * value + (c - '0');
}
if (in[0] == '-') value *= -1;
return is;
}
signed main(){
int N, M, p;
cin >> N >> M >> p;
long P = p * power(100, mod - 2, mod) % mod;
long V[N];
for(int i = 0; i < N; i++){
cin >> V[i];
}
long ans = 0, sum = 0;
for(int i = 0; i < N; i++){
ans += sum * power((1 - P + mod) % mod, i, mod) % mod * power(P, M - 1, mod) % mod * table.C(i + M - 1, i) % mod * P % mod;
sum = (sum + V[i]) % mod;
}
for(int i = 0; i < M; i++){
ans += sum * power((1 - P + mod) % mod, N - 1, mod) % mod * power(P, i, mod) % mod * table.C(i + N - 1, i) % mod * (1 - P + mod) % mod;
}
cout << ans % mod << endl;
}