結果

問題 No.2452 Incline
ユーザー binapbinap
提出日時 2023-09-01 22:43:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 3,579 ms
コンパイル使用メモリ 227,112 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-01 22:43:52
合計ジャッジ時間 6,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 383 ms
4,376 KB
testcase_04 AC 321 ms
4,380 KB
testcase_05 AC 302 ms
4,376 KB
testcase_06 AC 346 ms
4,380 KB
testcase_07 AC 301 ms
4,380 KB
testcase_08 AC 249 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> P;
typedef long double ld;

using mint = modint998244353;

mint calc(ll n, ll m, ll x){
	m++; x++;
	ll p = m / (n - 1), q = m % (n - 1);
	ll a = x / (n - 1), b = x % (n - 1);
	mint loop = mint(p) * (n - 1) + mint(q);
	mint res = loop * a + mint(p) * (b) + mint(min(q, b));
	return res;
}

void solve(){
	ll n, m, l, r;
	cin >> n >> m >> l >> r;
//	rep(i, m + 1) cout << calc(n, m, i).val() << "\n";
	cout << (calc(n, m, r) - calc(n, m, l - 1)).val() << "\n";
}

int main(){
	int t;
	cin >> t;
	rep(i, t) solve();
	return 0;
}
0