結果
問題 | No.1276 3枚のカード |
ユーザー | akakimidori |
提出日時 | 2022-02-26 14:45:27 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 1,928 bytes |
コンパイル時間 | 11,678 ms |
コンパイル使用メモリ | 378,292 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-07-04 10:55:26 |
合計ジャッジ時間 | 15,591 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 58 ms
7,296 KB |
testcase_11 | AC | 28 ms
5,376 KB |
testcase_12 | AC | 36 ms
5,376 KB |
testcase_13 | AC | 36 ms
5,632 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 31 ms
5,376 KB |
testcase_16 | AC | 67 ms
7,808 KB |
testcase_17 | AC | 38 ms
5,504 KB |
testcase_18 | AC | 29 ms
5,376 KB |
testcase_19 | AC | 45 ms
6,016 KB |
testcase_20 | AC | 27 ms
5,376 KB |
testcase_21 | AC | 28 ms
5,376 KB |
testcase_22 | AC | 65 ms
7,680 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 41 ms
5,888 KB |
testcase_25 | AC | 15 ms
5,376 KB |
testcase_26 | AC | 48 ms
6,656 KB |
testcase_27 | AC | 55 ms
7,168 KB |
testcase_28 | AC | 54 ms
6,940 KB |
testcase_29 | AC | 33 ms
5,376 KB |
testcase_30 | AC | 6 ms
5,376 KB |
testcase_31 | AC | 5 ms
5,376 KB |
testcase_32 | AC | 15 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 10 ms
5,376 KB |
testcase_35 | AC | 11 ms
5,376 KB |
testcase_36 | AC | 1 ms
5,376 KB |
testcase_37 | AC | 9 ms
5,376 KB |
testcase_38 | AC | 7 ms
5,376 KB |
testcase_39 | AC | 16 ms
5,376 KB |
testcase_40 | AC | 60 ms
7,552 KB |
testcase_41 | AC | 49 ms
6,656 KB |
testcase_42 | AC | 54 ms
7,040 KB |
testcase_43 | AC | 48 ms
6,528 KB |
testcase_44 | AC | 67 ms
8,064 KB |
testcase_45 | AC | 61 ms
7,552 KB |
testcase_46 | AC | 60 ms
7,680 KB |
testcase_47 | AC | 49 ms
6,656 KB |
testcase_48 | AC | 49 ms
6,656 KB |
testcase_49 | AC | 56 ms
7,168 KB |
testcase_50 | AC | 61 ms
7,552 KB |
testcase_51 | AC | 54 ms
6,912 KB |
testcase_52 | AC | 46 ms
6,400 KB |
testcase_53 | AC | 53 ms
6,912 KB |
testcase_54 | AC | 57 ms
7,424 KB |
testcase_55 | AC | 45 ms
6,528 KB |
testcase_56 | AC | 48 ms
6,272 KB |
testcase_57 | AC | 59 ms
7,296 KB |
testcase_58 | AC | 61 ms
7,552 KB |
testcase_59 | AC | 51 ms
6,784 KB |
testcase_60 | AC | 68 ms
8,064 KB |
ソースコード
fn quot_range<F>(n: u32, mut f: F) where F: FnMut(u32, u32, u32) { let mut pre = (0, 0); for d in 1.. { let q = n / d; if pre != (0, 0) { let (q, l, r) = (pre.0, q + 1, pre.1); f(l, r, q); } if q < d { break; } pre = (d, q); f(d, d, q); if q == d { break; } } } fn read() -> u32 { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().parse().unwrap() } fn main() { let n = read(); const MOD: u64 = 1_000_000_007; let mut ans = 0; quot_range(n, |l, r, q| { let l = l as u64; let r = r as u64; let q = q as u64; let n = n as u64; ans += (r - l + 1) * (q - 1) * (n - 2) % MOD; ans += MOD - (r - l + 1) * (q - 1) * (q - 2) % MOD; }); let k = (n as f64 / (n as f64).ln_1p().ln_1p().max(1f64)).cbrt().powi(2) as u32; let mut memo = vec![0; k as usize + 1]; for b in 2..=k { for c in 2..=(k / b) { let v = (c - 1) as u64; memo[(b * c) as usize] += v; memo.get_mut((b * (c + 1)) as usize).map(|p| *p += MOD - v); } let x = b as usize; memo[x] = (memo[x] + memo[x - 1]) % MOD; } let mut large = vec![0; 1 + (n / k) as usize]; for i in (1..=(n / k)).rev() { let m = n / i; quot_range(m, |l, r, q| { if l > 1 { large[i as usize] += (r - l + 1) as u64 * (q - 1) as u64; } }); large[i as usize] %= MOD; } quot_range(n, |l, r, q| { if q <= 2 { return; } let w = (r - l + 1) as u64; let s = if q <= k { memo[q as usize] } else { large[(n / q) as usize] }; ans += MOD - s * w % MOD; }); ans %= MOD; println!("{}", ans); }