結果
問題 | No.2211 Frequency Table of GCD |
ユーザー | Today03 |
提出日時 | 2024-11-05 10:15:44 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 354 ms / 2,000 ms |
コード長 | 2,606 bytes |
コンパイル時間 | 3,160 ms |
コンパイル使用メモリ | 253,280 KB |
実行使用メモリ | 27,852 KB |
最終ジャッジ日時 | 2024-11-05 10:15:57 |
合計ジャッジ時間 | 11,398 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 223 ms
25,008 KB |
testcase_04 | AC | 156 ms
19,080 KB |
testcase_05 | AC | 231 ms
21,456 KB |
testcase_06 | AC | 191 ms
22,764 KB |
testcase_07 | AC | 286 ms
25,520 KB |
testcase_08 | AC | 16 ms
6,820 KB |
testcase_09 | AC | 12 ms
6,820 KB |
testcase_10 | AC | 30 ms
6,820 KB |
testcase_11 | AC | 23 ms
6,816 KB |
testcase_12 | AC | 35 ms
6,816 KB |
testcase_13 | AC | 144 ms
18,356 KB |
testcase_14 | AC | 268 ms
25,336 KB |
testcase_15 | AC | 202 ms
23,740 KB |
testcase_16 | AC | 234 ms
24,408 KB |
testcase_17 | AC | 199 ms
21,448 KB |
testcase_18 | AC | 335 ms
27,720 KB |
testcase_19 | AC | 331 ms
27,676 KB |
testcase_20 | AC | 342 ms
27,852 KB |
testcase_21 | AC | 327 ms
27,584 KB |
testcase_22 | AC | 354 ms
27,684 KB |
testcase_23 | AC | 225 ms
26,916 KB |
testcase_24 | AC | 299 ms
27,680 KB |
testcase_25 | AC | 32 ms
6,816 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 332 ms
27,688 KB |
testcase_28 | AC | 302 ms
27,704 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; template <ll MOD> struct ModInt { ll value; ModInt(ll x = 0) { value = (x >= 0 ? x % MOD : MOD - (-x) % MOD); } ModInt operator-() const { return ModInt(-value); } ModInt operator+() const { return ModInt(*this); } ModInt& operator+=(const ModInt& other) { value += other.value; if (value >= MOD) value -= MOD; return *this; } ModInt& operator-=(const ModInt& other) { value += MOD - other.value; if (value >= MOD) value -= MOD; return *this; } ModInt& operator*=(const ModInt other) { value = value * other.value % MOD; return *this; } ModInt& operator/=(ModInt other) { (*this) *= other.inv(); return *this; } ModInt operator+(const ModInt& other) const { return ModInt(*this) += other; } ModInt operator-(const ModInt& other) const { return ModInt(*this) -= other; } ModInt operator*(const ModInt& other) const { return ModInt(*this) *= other; } ModInt operator/(const ModInt& other) const { return ModInt(*this) /= other; } ModInt pow(ll x) const { ModInt ret(1), mul(value); while (x) { if (x & 1) ret *= mul; mul *= mul; x >>= 1; } return ret; } ModInt inv() const { return pow(MOD - 2); } bool operator==(const ModInt& other) const { return value == other.value; } bool operator!=(const ModInt& other) const { return value != other.value; } friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.value; } friend istream& operator>>(istream& is, ModInt& x) { ll v; is >> v; x = ModInt<MOD>(v); return is; } static constexpr ll get_mod() { return MOD; } }; using Mod998 = ModInt<998244353>; using Mod107 = ModInt<1000000007>; using mint = Mod998; int main() { int N, M; cin >> N >> M; vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i]; vector<vector<int>> div(M + 1); for (int i = 1; i <= M; i++) { for (int j = i; j <= M; j += i) { div[j].push_back(i); } } vector<int> ex(M + 1); for (int i = 0; i < N; i++) { for (int x : div[A[i]]) ex[x]++; } vector<mint> dp(M + 1); for (int i = M; i >= 1; i--) { dp[i] = mint(2).pow(ex[i]) - 1; for (int j = i * 2; j <= M; j += i) { dp[i] -= dp[j]; } } for (int i = 1; i <= M; i++) cout << dp[i] << '\n'; }