結果
問題 | No.2394 部分和乗総和 |
ユーザー | ueta |
提出日時 | 2023-07-29 03:06:16 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 8,343 bytes |
コンパイル時間 | 1,176 ms |
コンパイル使用メモリ | 162,800 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 03:42:36 |
合計ジャッジ時間 | 2,652 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | AC | 1 ms
6,816 KB |
testcase_09 | AC | 1 ms
6,820 KB |
testcase_10 | AC | 1 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 2 ms
6,816 KB |
testcase_13 | AC | 13 ms
6,816 KB |
testcase_14 | AC | 44 ms
6,816 KB |
testcase_15 | AC | 47 ms
6,816 KB |
testcase_16 | AC | 69 ms
6,816 KB |
testcase_17 | AC | 131 ms
6,816 KB |
testcase_18 | AC | 131 ms
6,820 KB |
testcase_19 | AC | 125 ms
6,820 KB |
testcase_20 | AC | 117 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> #include <cstdint> #define rp(n) for(int i=0;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define Per(i,sta,n) for(int i=n-1;i>=sta;i--) #define fore(i, a) for(auto &&i : a) #define foreP(a, b, v) for(auto &&[a, b] : v) #define foreP3(a, b, c, v) for(auto &&[a, b, c] : v) #define fitr(itr, m) for(auto &&itr=m.begin();itr!=m.end();itr++) #define all(v) (v).begin(),(v).end() #define Sum(a) accumulate(all(a),0LL) #define VC vector #define TP tuple using namespace std; mt19937 engine(time(0)); using ll = long long; using ld = long double; constexpr long long mod = 998244353; // constexpr long long mod = 1000000007; // constexpr long long mod = 100000000000000003; constexpr double PI=3.1415926535897932384626433832795028841971; constexpr long long inf = INT_MAX; constexpr long long infll = LONG_MAX; int dx[8] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[8] = {0, 1, 0,-1, 1,-1, 1,-1 }; using Si =set<int>; using Sll =set<long long>; using Sc =set<char>; using Ss =set<string>; using Mii = map<int,int>; using Msi = map<string,int>; using Mci = map<char,int>; using Mlli = map<long long,int>; using T3 = tuple<int, int, int>; using TL3 = tuple<long long,long long,long long>; using P = pair<int, int>; using PL = pair<long long, long long>; using V = vector<int>; using VL = vector<long long>; using Vc = vector<char>; using Vs = vector<string>; using VV = vector<vector<int>>; using VVL = vector<vector<long long>>; using VVV = vector<vector<vector<int>>>; using VP = vector<P>; using VVP = vector<vector<P>>; template<typename T>using MaxHeap = priority_queue<T>; template<typename T>using MinHeap = priority_queue<T, vector<T>, greater<T>>; template<typename T>void chmin(T& a, T b) {a = min(a, b);} template<typename T>void chmax(T& a, T b) {a = max(a, b);} ll modpow(ll x, ll n, ll m = mod) { if (n < 0) { ll res = modpow(x, -n, m); return modpow(res, m - 2, m); } if (abs(x) >= m)x %= m; if (x < 0)x += m; //if (x == 0)return 0; ll res = 1; while (n) { if (n & 1)res = res * x % m; x = x * x % m; n >>= 1; } return res; } class modint { public: int val; modint() :val(0) {} template<typename T>modint(T x=0): val(x%mod){if(val<0)val+=mod;} modint(const modint &r){val=r.val;} modint& operator=(const modint& other) {val = other.val;return *this;} modint& operator=(const int& other) {val = other;return *this;} modint& operator=(const long long& other) {val = other;return *this;} //算術演算子 modint operator +(){return (*this);} //単項 modint operator -(){return (val%mod+mod)%mod;} //単項 modint operator +(const modint &r){return modint(*this)+=r;} modint operator -(const modint &r){return modint(*this)-=r;} modint operator *(const modint &r){return modint(*this)*=r;} modint operator /(const modint &r){return modint(*this)/=r;} modint operator %(const modint &r){return modint(*this)%=r;} modint operator ^(long long r){modint ans = 1, x = val;while (r > 0) {if (r & 1) ans *= x;x *= x;r >>= 1;}return ans;} modint operator ++(int){val+=1;val%=mod; return *this;} modint operator --(int){(val==0)?val=mod-1:val-=1; return *this;} //代入演算子 modint &operator +=(const modint &r){val+=r.val;if(val>=mod)val-=mod;return *this;} modint &operator -=(const modint &r){if(val<r.val)val+=mod;val-=r.val;return *this;} modint &operator *=(const modint &r){val=(ll)val*r.val%mod;return *this;} modint &operator /=(const modint &r){ll a=r.val,b=mod,u=1,v=0;while(b){ll t=a/b;a-=t*b;swap(a,b);u-=t*v;swap(u,v);}val=val*u%mod;if(val<0)val+=mod;return *this;} modint &operator %=(const modint &r){val=val%r.val; return *this;} modint &operator ^=(const long long &r){(*this)=(*this)^r; return (*this);} //等価比較演算子 bool operator ==(const modint& r){return this->val==r.val;} bool operator <(const modint& r){return this->val<r.val;} bool operator >(const modint& r){return this->val>r.val;} bool operator !=(const modint& r){return this->val!=r.val;} // 他のクラスとの計算 template <typename T>friend modint operator+(T t, const modint& o) {return modint(t) + o;} template <typename T>friend modint operator-(T t, const modint& o) {return modint(t) - o;} template <typename T>friend modint operator*(T t, const modint& o) {return modint(t) * o;} template <typename T>friend modint operator/(T t, const modint& o) {return modint(t) / o;} }; istream &operator >>(istream &is,modint& x){ long long t; is >> t; x=modint(t); return is;} ostream &operator <<(ostream &os,const modint& x){return os<<x.val;} // modint combP(int a, int b) { // if (a < 0 || b < 0 || a < b)return 0; // return fact[a] * factinv[a - b]; // } ostream &operator<<(ostream &dest, __int128_t value) {ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; 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 (dest.rdbuf()->sputn(d, len) != len) dest.setstate(ios_base::badbit); } return dest; } __int128 parse(string &s) { __int128 ret = 0; for (int i = 0; i < s.size(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template<typename T> T gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b)swap(a, b); while(b){ll r = a % b; a = b; b = r;} return a; } template<typename T>void debug(T a){cerr << a << endl;} template<typename T,typename S>void debug(T a, S b){cerr << a << " " << b << endl;} template<typename T,typename S,typename U>void debug(T a,S b,U c){cerr <<"( "<< a << " " << b << " " << c <<" )" << endl;} template<typename T,typename S,typename U,typename W>void debug(T a,S b,U c,W d){cerr <<"( "<< a << " " << b << " " << c<< " " << d <<" )" << endl;} template<typename T>void debug(vector<T> v){for(int i=0;i<v.size();i++)cerr << v[i] << " ";cerr << endl;} template<typename T>void debug(set<T> m){for(auto itr: m){cerr << itr << " ";}cerr << endl;} template<typename T,typename S>void debug(map<T,S> m){for(auto itr=m.begin();itr!=m.end();itr++)cerr <<"("<< itr->first << " => " << itr->second<<")" << endl;} template<typename T,typename S>void debug(pair<T,S> p){cerr <<"( "<< p.first << ", " << p.second <<" )" << endl;} template<typename T,typename S>void debug(tuple<T,S> t){cerr <<"( "<< get<0>(t) << ", " << get<1>(t) <<" )" << endl;} template<typename T,typename S,typename U>void debug(tuple<T,S,U> t){cerr <<"( "<< get<0>(t) << ", " << get<1>(t)<< ", " << get<2>(t) <<" )" << endl;} template<typename T,typename S,typename U,typename W>void debug(tuple<T,S,U,W> t){cerr <<"( "<< get<0>(t) << ", " << get<1>(t)<< ", " << get<2>(t)<< ", " << get<3>(t) <<" )" << endl;} template<typename T>void out(T a){ cout << a << endl;} template<typename T,typename S>void out(T a,S b){ cout << a <<" " << b << endl;} template<typename T,typename S,typename U>void out(T a,S b,U c){ cout << a <<" " << b <<" " << c << endl;} template<typename T>void out(vector<T> v){ for(int i=0;i<v.size();i++){cout << v[i];if(i==v.size()-1) cout << endl;else cout << " ";}} template<typename T>void out(set<T> m){for(auto itr: m){cout << itr; if((itr+1)==m.endl()) cout << endl;else cout << " ";}} template<typename T,typename S>void out(pair<T,S> p){cout << p.first << " " << p.second << endl;} template<typename T,typename S>void out(tuple<T,S> t){cout << get<0>(t) << " " << get<1>(t) << endl;} template<typename T,typename S,typename U>void out(tuple<T,S,U> t){cout << get<0>(t) << " " << get<1>(t)<< " " << get<2>(t) << endl;} void yes(bool f=1,string yes="Yes",string no="No"){if(f){cout << yes << endl;}else{cout << no << endl;}} struct S { int x; int y; S(int x, int y) : x(x),y(y){} bool operator<(const struct S& other) const { return x < other.x; } void debug(){ cerr <<"debug " << x <<"-" << y << endl; } }; void solve(){ ll n,m,b; cin >> n >> m >> b; VL a(n); rep(i,n) cin >> a[i]; ll ans = 1; rep(i,n){ ans*=(1+modpow(m,a[i],b))%b; ans %= b; } out(ans); return; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout<<std::setprecision(20); int t=1; // cin >> t; while(t--) solve(); return 0; }