結果
問題 | No.2452 Incline |
ユーザー | KumaTachiRen |
提出日時 | 2023-09-01 21:57:15 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 1,262 bytes |
コンパイル時間 | 4,473 ms |
コンパイル使用メモリ | 260,024 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-01 21:57:22 |
合計ジャッジ時間 | 6,110 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 121 ms
4,376 KB |
testcase_04 | AC | 104 ms
4,376 KB |
testcase_05 | AC | 97 ms
4,376 KB |
testcase_06 | AC | 103 ms
4,376 KB |
testcase_07 | AC | 99 ms
4,376 KB |
testcase_08 | AC | 83 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define writejoin(s, a) rep(_i, 0, (a).size()) cout << (a)[_i] << (_i + 1 < (int)(a).size() ? s : "\n"); #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; using ll = long long; using mint = modint998244353; mint fs(ll m, ll a, ll b) { a -= m; // sum[x=0~m]floor((x+a)/b); ll r = a % b; if (r < 0) r += b; mint ret = mint(m + 1) * ((a - r) / b); a = r; m += a + 1; // sum[x=0~m-1]floor(x/b); ll n = m / b; ret += mint(m % b) * n; ret += mint(b) * n * (n - 1) / 2; return ret; } int main() { int t; cin >> t; while (t--) { ll n, m, l, r; cin >> n >> m >> l >> r; mint ans = m + 1; ans += fs(m, r, n - 1); ans -= fs(m, l + n - 2, n - 1); cout << ans.val() << "\n"; } }