結果

問題 No.766 金魚すくい
ユーザー ミドリムシミドリムシ
提出日時 2018-12-14 14:36:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 4,070 bytes
コンパイル時間 898 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 160,948 KB
最終ジャッジ日時 2023-10-25 10:00:16
合計ジャッジ時間 15,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 197 ms
159,124 KB
testcase_01 AC 197 ms
159,048 KB
testcase_02 AC 195 ms
159,032 KB
testcase_03 WA -
testcase_04 AC 196 ms
159,100 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 199 ms
159,100 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 386 ms
160,684 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 244 ms
159,032 KB
testcase_36 AC 242 ms
159,100 KB
testcase_37 AC 398 ms
160,916 KB
testcase_38 AC 402 ms
160,684 KB
testcase_39 AC 385 ms
160,848 KB
testcase_40 AC 390 ms
160,684 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 196 ms
159,032 KB
testcase_44 AC 196 ms
159,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0