結果
問題 | No.2452 Incline |
ユーザー | shobonvip |
提出日時 | 2023-09-01 23:20:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,433 bytes |
コンパイル時間 | 4,318 ms |
コンパイル使用メモリ | 259,264 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-01 23:20:30 |
合計ジャッジ時間 | 6,462 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 145 ms
4,380 KB |
testcase_04 | AC | 131 ms
4,384 KB |
testcase_05 | AC | 122 ms
4,376 KB |
testcase_06 | AC | 127 ms
4,376 KB |
testcase_07 | AC | 123 ms
4,380 KB |
testcase_08 | AC | 107 ms
4,380 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } mint calc(ll n, ll k){ ll l = (k+1) / (n-1); return mint(k+1) * (l+1) - mint(n-1) * l * (l+1) * mint(2).inv(); } void solve(){ ll n, m, l, r; cin >> n >> m >> l >> r; mint ans = calc(n, r) - calc(n, l-1) + calc(n, m-l) - calc(n, m-r-1); ans -= (r-l+1); cout << ans.val() << '\n'; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) solve(); }