結果

問題 No.2891 Mint
ユーザー kotatsugame
提出日時 2024-09-13 21:47:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 67,584 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 21:47:53
合計ジャッジ時間 3,567 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long N,M;
	cin>>N>>M;
	mint ans=0;
	const mint inv2=mint(2).inv();
	long kl=1;
	while(kl<=N)
	{
		long q=M/kl;
		long kr=q==0?N:min(N,M/q);
		ans+=mint(kr-kl+1)*M;
		ans-=(mint(kr)*(kr+1)*inv2-mint(kl)*(kl-1)*inv2)*q;
		kl=kr+1;
	}
	cout<<ans.val()<<endl;
}
0