結果

問題 No.2211 Frequency Table of GCD
ユーザー 👑 kmjpkmjp
提出日時 2023-02-10 21:53:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 288 ms / 2,000 ms
コード長 1,194 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 199,032 KB
実行使用メモリ 7,484 KB
最終ジャッジ日時 2023-09-22 01:05:26
合計ジャッジ時間 8,902 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,936 KB
testcase_01 AC 4 ms
4,956 KB
testcase_02 AC 4 ms
4,956 KB
testcase_03 AC 244 ms
7,360 KB
testcase_04 AC 184 ms
6,500 KB
testcase_05 AC 210 ms
6,656 KB
testcase_06 AC 231 ms
6,888 KB
testcase_07 AC 259 ms
7,116 KB
testcase_08 AC 9 ms
4,956 KB
testcase_09 AC 7 ms
4,892 KB
testcase_10 AC 13 ms
4,948 KB
testcase_11 AC 11 ms
5,216 KB
testcase_12 AC 14 ms
4,976 KB
testcase_13 AC 175 ms
6,484 KB
testcase_14 AC 246 ms
7,076 KB
testcase_15 AC 232 ms
7,148 KB
testcase_16 AC 242 ms
7,036 KB
testcase_17 AC 214 ms
6,916 KB
testcase_18 AC 286 ms
7,296 KB
testcase_19 AC 285 ms
7,348 KB
testcase_20 AC 286 ms
7,236 KB
testcase_21 AC 285 ms
7,340 KB
testcase_22 AC 288 ms
7,484 KB
testcase_23 AC 254 ms
6,780 KB
testcase_24 AC 279 ms
6,556 KB
testcase_25 AC 14 ms
5,136 KB
testcase_26 AC 4 ms
4,948 KB
testcase_27 AC 284 ms
7,232 KB
testcase_28 AC 280 ms
6,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,C[202020];

ll dp[202020];
ll p2[202020];
const ll mo=998244353;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	p2[0]=1;
	FOR(i,201010) p2[i+1]=p2[i]*2%mo;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>x;
		C[x]++;
	}
	for(i=M;i>=1;i--) {
		int num=0;
		for(j=i;j<=M;j+=i) num+=C[j];
		dp[i]=p2[num]-1;
		for(j=2*i;j<=M;j+=i) dp[i]+=mo-dp[j];
		dp[i]%=mo;
	}
	
	FOR(i,M) cout<<dp[i+1]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0