結果
問題 | No.2963 Mecha DESU |
ユーザー | soto800 |
提出日時 | 2024-11-16 18:07:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 547 ms / 2,000 ms |
コード長 | 5,430 bytes |
コンパイル時間 | 2,271 ms |
コンパイル使用メモリ | 209,412 KB |
実行使用メモリ | 17,588 KB |
最終ジャッジ日時 | 2024-11-16 18:07:26 |
合計ジャッジ時間 | 16,383 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 1 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 509 ms
17,188 KB |
testcase_14 | AC | 491 ms
17,208 KB |
testcase_15 | AC | 499 ms
17,208 KB |
testcase_16 | AC | 460 ms
17,280 KB |
testcase_17 | AC | 483 ms
17,168 KB |
testcase_18 | AC | 489 ms
17,248 KB |
testcase_19 | AC | 477 ms
17,196 KB |
testcase_20 | AC | 263 ms
12,672 KB |
testcase_21 | AC | 103 ms
9,984 KB |
testcase_22 | AC | 46 ms
5,760 KB |
testcase_23 | AC | 81 ms
8,320 KB |
testcase_24 | AC | 278 ms
11,520 KB |
testcase_25 | AC | 255 ms
14,080 KB |
testcase_26 | AC | 316 ms
13,692 KB |
testcase_27 | AC | 140 ms
8,448 KB |
testcase_28 | AC | 379 ms
15,744 KB |
testcase_29 | AC | 279 ms
13,312 KB |
testcase_30 | AC | 17 ms
5,248 KB |
testcase_31 | AC | 143 ms
9,984 KB |
testcase_32 | AC | 55 ms
5,504 KB |
testcase_33 | AC | 304 ms
14,080 KB |
testcase_34 | AC | 278 ms
14,720 KB |
testcase_35 | AC | 88 ms
7,040 KB |
testcase_36 | AC | 245 ms
12,416 KB |
testcase_37 | AC | 85 ms
9,088 KB |
testcase_38 | AC | 101 ms
6,656 KB |
testcase_39 | AC | 329 ms
12,928 KB |
testcase_40 | AC | 192 ms
8,320 KB |
testcase_41 | AC | 263 ms
13,312 KB |
testcase_42 | AC | 274 ms
12,800 KB |
testcase_43 | AC | 408 ms
16,576 KB |
testcase_44 | AC | 339 ms
15,232 KB |
testcase_45 | AC | 296 ms
12,544 KB |
testcase_46 | AC | 191 ms
9,728 KB |
testcase_47 | AC | 231 ms
9,472 KB |
testcase_48 | AC | 104 ms
7,680 KB |
testcase_49 | AC | 163 ms
8,320 KB |
testcase_50 | AC | 547 ms
17,548 KB |
testcase_51 | AC | 507 ms
17,492 KB |
testcase_52 | AC | 469 ms
17,588 KB |
testcase_53 | AC | 407 ms
11,264 KB |
testcase_54 | AC | 402 ms
11,392 KB |
testcase_55 | AC | 2 ms
5,248 KB |
testcase_56 | AC | 2 ms
5,248 KB |
testcase_57 | AC | 32 ms
11,324 KB |
testcase_58 | AC | 67 ms
9,344 KB |
testcase_59 | AC | 2 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; #define lli long long int #define REP(i, s, n) for (lli i = s; i < n; i++) #define INF (1LL << 62) #define mp(a, b) make_pair(a, b) #define SORT(V) sort(V.begin(), V.end()) #define PI (3.141592653589794) #define TO_STRING(VariableName) #VariableName #define LOG1(x) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << endl; #define LOG2(x, y) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << endl; #define LOG3(x, y, z) \ if (DEBUG) \ cout << TO_STRING(x) << "=" << x << " " << TO_STRING(y) << "=" << y << " " \ << TO_STRING(z) << "=" << z << endl; #define LOG4(w, x, y, z) \ if (DEBUG) \ cout << TO_STRING(w) << "=" << w << " " << TO_STRING(x) << "=" << x << " " \ << TO_STRING(y) << "=" << y << " " << TO_STRING(z) << "=" << z \ << endl; #define LOG5(w, x, y, z, a) \ if (DEBUG) \ cout << TO_STRING(w) << "=" << w << " " << TO_STRING(x) << "=" << x << " " \ << TO_STRING(y) << "=" << y << " " << TO_STRING(z) << "=" << z << " " \ << TO_STRING(a) << "=" << a << endl; #define LOG6(w, x, y, z, a, b) \ if (DEBUG) \ cout << TO_STRING(w) << "=" << w << " " << TO_STRING(x) << "=" << x << " " \ << TO_STRING(y) << "=" << y << " " << TO_STRING(z) << "=" << z << " " \ << TO_STRING(a) << "=" << a << " " << TO_STRING(b) << "=" << b \ << endl; #define overload6(a, b, c, d, e, f, g, ...) g #define LOG(...) \ overload6(__VA_ARGS__, LOG6, LOG5, LOG4, LOG3, LOG2, LOG1)(__VA_ARGS__) 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 (b < a) { a = b; return 1; } return 0; } mt19937 engine; std::chrono::system_clock::time_point start, endTime; #define DEBUG 1 // modint: mod 計算を int を扱うように扱える構造体 template <int MOD> struct Fp { long long val; constexpr Fp(long long v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr int getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; const int MOD = 998244353; using mint = Fp<MOD>; mint pSum[1000100]; void solve() { // write your code here lli N, M, K; cin >> N >> M >> K; map<lli, lli> cnts; REP(i, 0, M) { lli a; cin >> a; cnts[a]++; } REP(i, 0, N + 1) { pSum[i] = 0; } for (auto e : cnts) { auto nowNum = e.first; auto nowCnt = e.second; for (int i = nowNum; i <= N; i += nowNum) { pSum[i] += nowCnt; } } mint ans = 0; REP(i, 1, N + 1) { mint p = pSum[i] / M; mint pp = (mint)1 - p; mint ppp = modpow(pp, K); ans += mint(1) - ppp; } cout << ans << endl; } // Generated by 2.13.0 https://github.com/kyuridenamida/atcoder-tools (tips: // You use the default template now. You can remove this line by using your // custom template) int main() { // Failed to predict input format lli N = 1; // cin >> N; while (N--) solve(); return 0; }