結果

問題 No.2891 Mint
ユーザー anago-pieanago-pie
提出日時 2024-09-19 13:55:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,618 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 208,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 13:55:31
合計ジャッジ時間 4,267 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 0
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int MOD = 1000000007;
const double pi = atan2(0, -1);
const int inf = 1 << 31-1;
const ll INF = 1LL << 63 - 1;
#include <time.h>
#include <chrono>

//vectorの中身を空白区切りで出力
template<typename T>
void printv(vector<T> v) {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i < v.size() - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

//vectorの中身を改行区切りで出力
template<typename T>
void print1(vector<T> v) {
	for (auto x : v) {
		cout << x << endl;
	}
}

//二次元配列を出力
template<typename T>
void printvv(vector<vector<T>> vv) {
	for (vector<T> v : vv) {
		printv(v);
	}
}

//vectorを降順にソート
template<typename T>
void rsort(vector<T>& v) {
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
}

//昇順priority_queueを召喚
template<typename T>
struct rpriority_queue {
	priority_queue<T, vector<T>, greater<T>> pq;

	void push(T x) {
		pq.push(x);
	}

	void pop() {
		pq.pop();
	}

	T top() {
		return pq.top();
	}

	size_t size() {
		return pq.size();
	}

	bool empty() {
		return pq.empty();
	}
};

//mod mod下で逆元を算出する
//高速a^n計算(mod ver.)
ll power(ll a, ll n) {
	if (n == 0) {
		return 1;
	}
	else if (n % 2 == 0) {
		ll x = power(a, n / 2);
		x *= x;
		x %= mod;
		return x;
	}
	else {
		ll x = power(a, n - 1);
		x *= a;
		x %= mod;
		return x;
	}
}
//フェルマーの小定理を利用
ll modinv(ll p) {
	return power(p, mod - 2) % mod;
}

//Mexを求める
struct Mex {
	map<int, int> mp;
	set<int> s;
	Mex(int Max) {
		for (int i = 0; i <= Max; i++) {
			s.insert(i);
		}
	}

	int _mex = 0;
	void Input(int x) {
		mp[x]++;
		s.erase(x);
		if (_mex == x) {
			_mex = *begin(s);
		}
	}

	void Remove(int x) {
		if (mp[x] == 0) {
			cout << "Mex ERROR!: NO VALUE WILL BE REMOVED" << endl;
		}
		mp[x]--;
		if (mp[x] == 0) {
			s.insert(x);
			if (*begin(s) == x) {
				_mex = x;
			}
		}
	}

	int mex(){
		return _mex;
	}
};

int main() {
	ll N, M;
	cin >> N >> M;

	ll ans = 0;

	ll k = 1;
	while (k <= N) {
		ll r = M % k;
		ll s = M / k;
		if (k > M) {
			ll t = (N - k + 1)%mod;
			ans += ((M % mod) * t) % mod;
			ans %= mod;
			k = N + 1;
		}
		else {
			ll t = min(r / s, N - k);
			ans += (((r % mod) * ((t + 1) % mod)) % mod - ((s % mod) * ((t * (t + 1) / 2) % mod)) % mod + mod) % mod;
			ans %= mod;
			k += t + 1;
		}
	}

	cout << ans << endl;
}
0