結果
問題 | No.1145 Sums of Powers |
ユーザー | beet |
提出日時 | 2020-07-31 22:03:51 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,114 bytes |
コンパイル時間 | 2,715 ms |
コンパイル使用メモリ | 218,900 KB |
実行使用メモリ | 9,292 KB |
最終ジャッジ日時 | 2023-09-20 23:25:20 |
合計ジャッジ時間 | 5,897 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,756 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 9 ms
4,380 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} using Int = long long; const char newl = '\n'; template<typename T,T MOD = 1000000007> struct Mint{ static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0) v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1) res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} bool operator <(const Mint a)const{return v <a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i<k;i++){ num*=Mint(n-i); dom*=Mint(i+1); } return num/dom; } }; template<typename T,T MOD> constexpr T Mint<T, MOD>::mod; template<typename T,T MOD> ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;} template<typename T> map<T, int> factorize(T x){ map<T, int> res; for(int i=2;i*i<=x;i++){ while(x%i==0){ x/=i; res[i]++; } } if(x!=1) res[x]++; return res; } template<typename T> T mod_pow(T a,long long n,T mod){ using ll = long long; T res(1); while(n){ if(n&1) res=(ll)res*a%mod; a=(ll)a*a%mod; n>>=1; } return res; } template<typename T> T order(T x,T MOD){ static map<T, vector<T>> dp; vector<T> &ps=dp[MOD]; if(ps.empty()){ auto fs=factorize(MOD-1); for(auto p:fs) ps.emplace_back(p.first); } T res=MOD-1; for(T p:ps){ while(res%p==0){ if(mod_pow(x,res/p,MOD)!=1) break; res/=p; } } return res; } //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,m; cin>>n>>m; vector<int> as(n); for(int i=0;i<n;i++) cin>>as[i]; using M = Mint<int, 998244353>; map<int, vector<int>> mp; for(int a:as) mp[order(a,M::mod)].emplace_back(a); vector<M> ans(m+1,0); for(auto p:mp){ map<int, int> cnt; for(int a:p.second) cnt[a]++; int len=min(p.first,m+1); vector<M> tmp(len,0); for(auto q:cnt){ M res(q.second); for(int i=0;i<len;i++){ tmp[i]+=res; res*=M(q.first); } } for(int i=0;i<=m;i++) ans[i]+=tmp[i%len]; } for(int i=1;i<=m;i++){ if(i!=1) cout<<' '; cout<<ans[i]; } cout<<newl; return 0; }