結果
問題 | No.864 四方演算 |
ユーザー | kaito_tateyama |
提出日時 | 2019-08-16 22:31:36 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,157 bytes |
コンパイル時間 | 14,264 ms |
コンパイル使用メモリ | 388,436 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 18:29:45 |
合計ジャッジ時間 | 15,364 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 10 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 10 ms
6,940 KB |
testcase_08 | AC | 8 ms
6,940 KB |
testcase_09 | WA | - |
testcase_10 | AC | 5 ms
6,944 KB |
testcase_11 | AC | 3 ms
6,944 KB |
testcase_12 | AC | 9 ms
6,940 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 12 ms
6,944 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 9 ms
6,940 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 8 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 1 ms
6,940 KB |
testcase_28 | AC | 1 ms
6,940 KB |
testcase_29 | AC | 1 ms
6,944 KB |
コンパイルメッセージ
warning: unused import: `std::cmp::max` --> src/main.rs:66:9 | 66 | use std::cmp::max; | ^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `std::cmp::min` --> src/main.rs:67:9 | 67 | use std::cmp::min; | ^^^^^^^^^^^^^ warning: unnecessary parentheses around assigned value --> src/main.rs:87:34 | 87 | ... res*=(2*limit - i+1); | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 87 - res*=(2*limit - i+1); 87 + res*=2*limit - i+1; | warning: unnecessary parentheses around assigned value --> src/main.rs:89:34 | 89 | ... res*=(i-1); | ^ ^ | help: remove these parentheses | 89 - res*=(i-1); 89 + res*=i-1; | warning: unnecessary parentheses around assigned value --> src/main.rs:92:34 | 92 | ... res*=(2*limit - n/i+1); | ^ ^ | help: remove these parentheses | 92 - res*=(2*limit - n/i+1); 92 + res*=2*limit - n/i+1; | warning: unnecessary parentheses around assigned value --> src/main.rs:94:34 | 94 | ... res*=(n/i-1); | ^ ^ | help: remove these parentheses | 94 - res*=(n/i-1); 94 + res*=n/i-1; | warning: value assigned to `ans` is never read --> src/main.rs:110:13 | 110 | let mut ans:i64 = 0; | ^^^ | = help: maybe it is overwritten before being read? = note: `#[warn(unused_assignments)]` on by default
ソースコード
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[allow(unused_macros)] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[allow(unused_macros)] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } mod vig { use std::cmp::max; use std::cmp::min; /// prime_factor /// usage: for (div, exp) in prime_factor(n) {...} pub fn prime_factor(n: i64, limit:i64) -> i64 { let mut ans:i64 = 0; for i in 2..((n as f64).sqrt() as i64+1) { if n%i==0 { if n/i >= 2&& n/i <=2*limit && i >= 2 && i <=2*limit { // println!("i: {}", i); if n/i == i { if 1 < i-limit { ans+=(2*limit - i+1)*(2*limit - i+1); }else{ ans+=(i-1)*(i-1); } assert_eq!(1,2); }else{ let mut res = 1; if 1 < i-limit { res*=(2*limit - i+1); }else{ res*=(i-1); } if 1 < n/i-limit { res*=(2*limit - n/i+1); }else{ res*=(n/i-1); } ans+=2*res; } } } } ans } } fn main() { input!{ n:i64, k:i64, } let mut ans:i64 = 0; if k<4 || 4*n*n < k { ans =0; }else{ ans = vig::prime_factor(k, n); } println!("{}", ans); }