結果
問題 | No.3095 Many Min Problems |
ユーザー |
![]() |
提出日時 | 2025-02-09 16:55:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 4,213 ms |
コンパイル使用メモリ | 250,572 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-02-24 20:39:47 |
合計ジャッジ時間 | 6,473 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; using mint = modint998244353; // Calculate sum of geometric sequence: s + sr + sr^2 + ... + sr^{N-1} mint sum_of_geometric_sequence(mint s, mint r, ll N) { if (r == 1) return s * N; return s * (r.pow(N) - 1) / (r - 1); } int main() { ll N, M; cin >> N >> M; mint ans = 0; for (int c = 1; c <= M; c++) { mint r = (mint)c / (mint)M; ans += sum_of_geometric_sequence(r, r, N); } ans *= ((mint)M).pow(N); cout << ans.val() << endl; }