結果

問題 No.2685 Cell Proliferation (Easy)
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-20 21:50:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 2,219 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 204,976 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 21:50:12
合計ジャッジ時間 3,331 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 20 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 11 ms
6,676 KB
testcase_04 AC 13 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 8 ms
6,676 KB
testcase_07 AC 10 ms
6,676 KB
testcase_08 AC 10 ms
6,676 KB
testcase_09 AC 15 ms
6,676 KB
testcase_10 AC 8 ms
6,676 KB
testcase_11 AC 6 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 10 ms
6,676 KB
testcase_14 AC 11 ms
6,676 KB
testcase_15 AC 19 ms
6,676 KB
testcase_16 AC 11 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 8 ms
6,676 KB
testcase_19 AC 9 ms
6,676 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 17 ms
6,676 KB
testcase_23 AC 5 ms
6,676 KB
testcase_24 AC 20 ms
6,676 KB
testcase_25 AC 14 ms
6,676 KB
testcase_26 AC 10 ms
6,676 KB
testcase_27 AC 4 ms
6,676 KB
testcase_28 AC 11 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){if(v == b.v) return true; else return false;}
    bool operator!=(mint b){if(v != b.v) return true; else return false;}
    bool operator>(mint b){if(v > b.v) return true; else return false;}
    bool operator>=(mint b){if(v >= b.v) return true; else return false;}
    bool operator<(mint b){if(v < b.v) return true; else return false;}
    bool operator<=(mint b){if(v <= b.v) return true; else return false;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    mint p1,p2,q1,q2;
    cin >> p1.v >> p2.v >> q1.v >> q2.v;
    int T; cin >> T;

    mint P = p1/p2,Q = q1/q2;
    vector<mint> pq(T+1,1);
    for(int i=1; i<=T; i++) pq.at(i) = pq.at(i-1)*Q;

    mint answer = 0;
    vector<mint> time(T+1);
    time.at(0) = 1;
    for(int i=0; i<T; i++){
        mint alive = time.at(i);
        for(int k=i+1; k<=T; k++){
            time.at(k) += alive*P;
            alive *= pq.at(k-i);
        }
        answer += alive;
    }

    answer += time.at(T);
    cout << answer.v << endl;
}
0