結果
| 問題 |
No.2880 Max Sigma Mod
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-09-23 01:33:52 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2,713 ms / 3,000 ms |
| コード長 | 768 bytes |
| コンパイル時間 | 12,399 ms |
| コンパイル使用メモリ | 386,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-23 01:34:42 |
| 合計ジャッジ時間 | 48,464 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
use std::cmp;
fn calc(x: i64, m: i64) -> i64 {
let mut ans = x * m;
let mut ind = 1;
while ind <= m {
let k = x / ind;
if k == 0 {
break;
}
let max_ind = x / k;
let max_ind = cmp::min(max_ind, m);
ans -= (ind + max_ind) * (max_ind - ind + 1) * k / 2;
ind = max_ind + 1;
}
ans
}
fn main() {
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let parts: Vec<i64> = input
.trim()
.split_whitespace()
.map(|s| s.parse().unwrap())
.collect();
let n = parts[0];
let m = parts[1];
let mut ans = 0;
for i in 0..=n {
ans = cmp::max(ans, calc(i, m));
}
println!("{}", ans);
}
titia