結果

問題 No.2211 Frequency Table of GCD
ユーザー planesplanes
提出日時 2023-02-10 21:42:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 871 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 178,040 KB
実行使用メモリ 53,332 KB
最終ジャッジ日時 2023-09-22 01:01:59
合計ジャッジ時間 16,318 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 546 ms
36,336 KB
testcase_04 AC 442 ms
31,168 KB
testcase_05 AC 575 ms
37,136 KB
testcase_06 AC 551 ms
36,760 KB
testcase_07 AC 707 ms
43,488 KB
testcase_08 AC 18 ms
4,380 KB
testcase_09 AC 13 ms
4,380 KB
testcase_10 AC 36 ms
4,404 KB
testcase_11 AC 26 ms
4,380 KB
testcase_12 AC 39 ms
4,388 KB
testcase_13 AC 419 ms
29,644 KB
testcase_14 AC 621 ms
40,076 KB
testcase_15 AC 537 ms
36,376 KB
testcase_16 AC 597 ms
38,840 KB
testcase_17 AC 574 ms
36,500 KB
testcase_18 AC 809 ms
48,688 KB
testcase_19 AC 827 ms
49,036 KB
testcase_20 AC 815 ms
48,828 KB
testcase_21 AC 871 ms
48,592 KB
testcase_22 AC 866 ms
48,848 KB
testcase_23 AC 616 ms
39,340 KB
testcase_24 AC 682 ms
40,676 KB
testcase_25 AC 34 ms
4,748 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 752 ms
53,332 KB
testcase_28 AC 676 ms
40,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll mod=998244353;


int main() {
ll N,M;cin>>N>>M;
map<ll,ll> A;
for(ll i=0;i<N;i++) {
  ll a;cin>>a;
  A[a]++;
}




vector<vector<ll>> note(M+1,vector<ll> (0));
for(ll i=1;i<=M;i++) {
  for(ll j=1;j*i<=M;j++) {
    note[i*j].push_back(i);
  }
}

vector<ll> memo(M+1,0);


for(auto x:A) {
  for(auto t:note[x.first]) {
    memo[t]+=x.second;
  }
}

vector<ll> t(N+1);
t[0]=1;
for(ll i=1;i<=N;i++) {
  t[i]=t[i-1]*2;
  t[i]%=mod;
}

vector<ll> dp(M+1,0);
for(ll i=M;i>=1;i--) {
  dp[i]=t[memo[i]]-1;
  for(ll j=2;i*j<=M;j++) {
    dp[i]-=dp[i*j];
    dp[i]%=mod;
  }
}

for(ll i=1;i<=M;i++) {
  dp[i]%=mod;
  if(dp[i]<0) dp[i]+=mod;
  cout<<dp[i]<<endl;
}
}

0