結果
問題 | No.1383 Numbers of Product |
ユーザー | koba-e964 |
提出日時 | 2021-12-27 18:31:15 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,194 bytes |
コンパイル時間 | 13,794 ms |
コンパイル使用メモリ | 377,372 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 12:12:39 |
合計ジャッジ時間 | 16,243 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
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 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 12 ms
5,376 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 12 ms
5,376 KB |
testcase_45 | WA | - |
testcase_46 | AC | 5 ms
5,376 KB |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::Read; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok().unwrap(); ret } 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; } } } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() } fn nth(a: i64, n: i64) -> i64 { let mut pass = 0; let mut fail = std::cmp::min(a, 1 << ((64 + n - 1) / n)) + 1; while fail - pass > 1 { let mid = (fail + pass) / 2; let mut tmp = 1i64; for _ in 0..n { tmp = tmp.saturating_mul(mid); } if tmp <= a { pass = mid; } else { fail = mid; } } pass } fn calc(x: i64, k: i64) -> (i64, bool) { let val = 4 * x + k * k; let y = nth(val, 2); ((y - k) / 2, y * y == val) } fn main() { let n: i64 = get(); let k: i64 = get(); let m: i64 = get(); let mut hm = HashMap::new(); for b in 3..19 { let mut x = 1; loop { let mut prod = 1i64; for i in x..x + b + 1 { prod = prod.saturating_mul(i); } if prod > n { break; } *hm.entry(prod).or_insert(0) += 1; x += 1; } } let mut ans = 0; let mut has = 0; for (&val, v) in hm.iter_mut() { if calc(val, k).1 { *v += 1; has += 1; } if *v == m { ans += 1; } } if m == 1 { let y = calc(n, k).0 - has; ans += y; } println!("{}", ans); }