結果
| 問題 |
No.2891 Mint
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-22 15:32:07 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 1,336 bytes |
| コンパイル時間 | 14,832 ms |
| コンパイル使用メモリ | 405,972 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-22 15:32:25 |
| 合計ジャッジ時間 | 17,629 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
use std::io::Read;
fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }
const MOD: i64 = 998_244_353;
fn triangle(x: i64) -> i64 {
let x = x % MOD;
x * (x - 1) / 2 % MOD
}
fn main() {
let n: i64 = get();
let m: i64 = get();
let mut x = 1;
while x * x <= m {
x += 1;
}
x -= 1;
let mut tot = (m % MOD) * (n % MOD) % MOD;
for i in 1..x + 1 {
if i <= n {
let q = m / i;
tot += MOD - (q * i) % MOD;
}
}
for j in 1..x + 1 {
let l = x.max(m / (j + 1));
let r = (m / j).min(n);
if l < r {
tot += MOD - ((r - l) % MOD) * j % MOD * ((l + 1) % MOD) % MOD;
tot += MOD - triangle(r - l) * j % MOD;
}
}
println!("{}", tot % MOD);
}