結果

問題 No.2963 Mecha DESU
ユーザー soto800
提出日時 2024-11-16 18:07:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 566 ms / 2,000 ms
コード長 5,430 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 202,180 KB
最終ジャッジ日時 2025-02-25 04:55:12
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0