結果
問題 |
No.3118 Increment or Multiply
|
ユーザー |
|
提出日時 | 2025-03-20 12:04:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 580 bytes |
コンパイル時間 | 4,488 ms |
コンパイル使用メモリ | 252,192 KB |
実行使用メモリ | 518,976 KB |
最終ジャッジ日時 | 2025-04-12 16:43:05 |
合計ジャッジ時間 | 11,015 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | MLE * 1 -- * 34 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; constexpr ll mod = 998244353; constexpr ll twoinv = 499122177; #define fast cin.tie(nullptr); ios_base::sync_with_stdio(false) ll t,n,a; mint s(ll x){ if(x <= 1) return 0; ll b = x / a,c = x - a * b; mint res = (c + 1); res *= b; mint pl = (x - b - 1); pl *= x - b; pl /= 2; return res + pl + s(b); } int main() { fast; cin >> t; while(t--){ cin >> n >> a; cout << s(n).val() << endl; } }