結果
問題 | No.2394 部分和乗総和 |
ユーザー | ゆにぽけ |
提出日時 | 2023-10-06 10:18:32 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 3,229 bytes |
コンパイル時間 | 1,401 ms |
コンパイル使用メモリ | 125,760 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-26 15:19:29 |
合計ジャッジ時間 | 3,380 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 1 ms
6,948 KB |
testcase_13 | AC | 10 ms
6,940 KB |
testcase_14 | AC | 38 ms
6,940 KB |
testcase_15 | AC | 41 ms
6,944 KB |
testcase_16 | AC | 59 ms
6,944 KB |
testcase_17 | AC | 108 ms
6,944 KB |
testcase_18 | AC | 107 ms
6,940 KB |
testcase_19 | AC | 107 ms
6,940 KB |
testcase_20 | AC | 95 ms
6,944 KB |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<cassert> #include<cmath> #include<ctime> #include<iomanip> #include<numeric> #include<stack> #include<queue> #include<map> #include<unordered_map> #include<set> #include<unordered_set> #include<bitset> #include<random> using namespace std; struct Modint { private: unsigned int value; static int &MOD() { static int mod = 0; return mod; } public: static void setmod(const int m) {MOD() = m;} Modint(const long long x = 0) noexcept { long long y = x; if(y < 0 || y >= MOD()) { y %= MOD(); if(y < 0) y += MOD(); } value = (unsigned int)y; } unsigned int &val() noexcept {return value;} Modint operator+(const Modint &other) noexcept { Modint tmp = *this; return tmp += other; } Modint operator-(const Modint &other) noexcept { Modint tmp = *this; return tmp -= other; } Modint operator*(const Modint &other) noexcept { Modint tmp = *this; return tmp *= other; } Modint operator/(const Modint &other) noexcept { Modint tmp = *this; return tmp /= other; } Modint &operator+=(const Modint &other) noexcept { value += other.value; if(value >= MOD()) value -= MOD(); return *this; } Modint &operator-=(const Modint &other) noexcept { unsigned long long x = value; if(x < other.value) x += MOD(); x -= other.value; value = (unsigned int) x; return *this; } Modint &operator*=(const Modint &other) noexcept { unsigned long long x = value; x *= other.value; value = (unsigned int)(x%MOD()); return *this; } Modint &operator/=(const Modint &other) noexcept { return *this = *this * other.inverse(); } Modint power(long ex) const noexcept { assert(ex >= 0); Modint p = *this,res = 1; while(ex) { if(ex & 1) res *= p; p *= p; ex >>= 1; } return res; } Modint inverse() const noexcept { assert(value); long long a = value,b = MOD(),x = 1,y = 0; while(b) { long long q = a/b; a -= q*b; swap(a,b); x -= q*y; swap(x,y); } return Modint(x); } Modint &operator++(int) noexcept {return *this += 1;} Modint &operator--(int) noexcept {return *this -= 1;} bool operator==(const Modint &other){return value == other.value;} bool operator!=(const Modint &other){return value != other.value;} friend ostream &operator<<(ostream &os,const Modint &x); }; ostream &operator<<(ostream &os,const Modint &x){os << x.value; return os;} using mint = Modint; long long N,M,B,A[1 << 17]; void solve() { cin >> N >> M >> B; for(int i = 0;i < N;i++) cin >> A[i]; mint::setmod(B); mint ans = 1; for(int i = 0;i < N;i++) ans *= (mint(M).power(A[i])+1); cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; //cin >> T; while(T--) solve(); }