結果
| 問題 |
No.2963 Mecha DESU
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-11-18 17:41:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,856 bytes |
| コンパイル時間 | 531 ms |
| コンパイル使用メモリ | 44,800 KB |
| 最終ジャッジ日時 | 2025-02-25 05:27:01 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 1 -- * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:66:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | scanf("%d%d%d", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:67:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
67 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2963.cc: No.2963 Mecha DESU - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000000;
const int MAX_M = 100000;
const int MOD = 998244353;
/* typedef */
template<const int MOD>
struct MI {
int v;
MI(): v() {}
MI(int _v): v(_v % MOD) { if (v < 0) v += MOD; }
MI(long long _v): v(_v % MOD) { if (v < 0) v += MOD; }
explicit operator int() const { return v; }
MI operator+(const MI m) const { return MI(v + m.v); }
MI operator-(const MI m) const { return MI(v + MOD - m.v); }
MI operator*(const MI m) const { return MI((long long)v * m.v); }
MI &operator+=(const MI m) { return (*this = *this + m); }
MI &operator-=(const MI m) { return (*this = *this - m); }
MI &operator*=(const MI m) { return (*this = *this * m); }
bool operator==(const MI m) const { return v == m.v; }
bool operator!=(const MI m) const { return v != m.v; }
MI pow(int n) const { // a^n % MOD
MI pm = 1, a = *this;
while (n > 0) {
if (n & 1) pm *= a;
a *= a;
n >>= 1;
}
return pm;
}
MI inv() const { return pow(MOD - 2); }
MI operator/(const MI m) const { return *this * m.inv(); }
MI &operator/=(const MI m) { return (*this = *this / m); }
};
using mi = MI<MOD>;
/* global variables */
int as[MAX_M], cs[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < n; i++) scanf("%d", as + i);
sort(as, as + m);
int mm = 0;
for (int i = 0; i < m;) {
int j = i;
while (i < m && as[j] == as[i]) i++;
for (int a = as[j]; a <= n; a += as[j]) cs[a] += i - j;
}
mi invm = mi(m).inv();
mi sum = 0;
for (int i = 1; i <= n; i++)
sum += mi(1) - (mi(m - cs[i]) * invm).pow(k);
printf("%d\n", (int)sum);
return 0;
}
tnakao0123