結果

問題 No.2211 Frequency Table of GCD
ユーザー warabi0906warabi0906
提出日時 2023-02-11 09:17:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 412 ms / 2,000 ms
コード長 2,176 bytes
コンパイル時間 3,868 ms
コンパイル使用メモリ 228,300 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-09-22 08:12:42
合計ジャッジ時間 13,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 320 ms
5,996 KB
testcase_04 AC 256 ms
5,736 KB
testcase_05 AC 307 ms
6,624 KB
testcase_06 AC 307 ms
6,260 KB
testcase_07 AC 368 ms
7,076 KB
testcase_08 AC 15 ms
4,380 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 29 ms
4,380 KB
testcase_11 AC 22 ms
4,380 KB
testcase_12 AC 30 ms
4,416 KB
testcase_13 AC 242 ms
5,684 KB
testcase_14 AC 341 ms
6,468 KB
testcase_15 AC 307 ms
5,940 KB
testcase_16 AC 326 ms
6,252 KB
testcase_17 AC 303 ms
6,772 KB
testcase_18 AC 410 ms
7,788 KB
testcase_19 AC 403 ms
7,908 KB
testcase_20 AC 408 ms
7,888 KB
testcase_21 AC 412 ms
7,968 KB
testcase_22 AC 407 ms
7,844 KB
testcase_23 AC 349 ms
6,356 KB
testcase_24 AC 408 ms
7,864 KB
testcase_25 AC 31 ms
4,712 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 401 ms
7,840 KB
testcase_28 AC 408 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "atcoder/all"
#define debug cout << "OK" << endl;
template<typename T>
inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }
inline int Code(char c) {
	if ('A' <= c and c <= 'Z')return (int)(c - 'A');
	if ('a' <= c and c <= 'z')return (int)(c - 'a');
	if ('0' <= c and c <= '9')return (int)(c - '0');
	assert(false);
}
using namespace std;
using namespace atcoder;
#define int long long
constexpr int MOD = 998244353;
constexpr int INF = (1LL << 63);
using minit = modint998244353;

template<typename T>
ostream& operator << (ostream& st, const vector<T>& v) {
	for (const T value : v) {
		st << value << " ";
	}
	return st;
}
template<typename T>
istream& operator >> (istream& st, vector<T>& v) {
	for (T& value : v) {
		st >> value;
	}
	return st;
}

struct edge {
	int to, cost;
};
int Rand() {
	return (rand() % 32768) * 32768 + (rand() % 32768);
}
int pow_(const int a, const int b, const int m = INF) {
	int res = 1;
	int base = a;
	for (int i = 0; i < 64; i++) {
		if (b & (1ll << i))res *= base;
		res %= m;
		base = base * base;
		base %= m;
	}
	return res;
}

//

//

class Solver {
public:
	int T;
	Solver() :T(1) {}
	~Solver(){}
	void multi();
	void solve() const;
	void sp(int x)const;
};
void Solver::multi() {
	cin >> T;
	return;
}
void Solver::sp(const int x)const {
	cout << fixed << setprecision(x) << endl;
	return;
}

void Solver::solve() const {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	cin >> A;
	vector<int> cnt(M + 1, 0);
	for (const int a : A) {
		cnt[a]++;
	}
	vector<int> ans(M + 1, 0);
	for (int k = M; 1 <= k; k--) {
		int pk = 0;
		minit res = 0;
		for (int e = 1; e * k <= M; e++) {
			pk += cnt[e * k];
			res -= ans[e * k];
		}
		res += pow_(2, pk, MOD) - 1;
		ans[k] = res.val();
	}
	for (int i = 1; i <= M; i++)
		cout << ans[i] << endl;
}

signed main() {
	Solver solver;
	//solver.multi();
	//solver.sp();
	for (int i = 0; i < solver.T; i++)
		solver.solve();
	return 0;
}

/*
* わらびのコードこーどすぺーす
 (σ・∀・)σゲッツ!!
*/
0