結果
問題 | No.864 四方演算 |
ユーザー | kaito_tateyama |
提出日時 | 2019-08-17 02:36:57 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 11 ms / 1,000 ms |
コード長 | 3,124 bytes |
コンパイル時間 | 12,459 ms |
コンパイル使用メモリ | 384,524 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 10:49:01 |
合計ジャッジ時間 | 13,465 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 11 ms
5,248 KB |
testcase_02 | AC | 7 ms
5,376 KB |
testcase_03 | AC | 8 ms
5,376 KB |
testcase_04 | AC | 10 ms
5,376 KB |
testcase_05 | AC | 8 ms
5,376 KB |
testcase_06 | AC | 10 ms
5,376 KB |
testcase_07 | AC | 9 ms
5,376 KB |
testcase_08 | AC | 8 ms
5,376 KB |
testcase_09 | AC | 5 ms
5,376 KB |
testcase_10 | AC | 4 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 8 ms
5,376 KB |
testcase_13 | AC | 7 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 11 ms
5,376 KB |
testcase_16 | AC | 8 ms
5,376 KB |
testcase_17 | AC | 9 ms
5,376 KB |
testcase_18 | AC | 9 ms
5,376 KB |
testcase_19 | AC | 6 ms
5,376 KB |
testcase_20 | AC | 10 ms
5,376 KB |
testcase_21 | AC | 9 ms
6,944 KB |
testcase_22 | AC | 8 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 7 ms
6,944 KB |
testcase_25 | AC | 4 ms
6,940 KB |
testcase_26 | AC | 8 ms
6,944 KB |
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:86:34 | 86 | ... res*=(2*limit - i+1); | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 86 - res*=(2*limit - i+1); 86 + res*=2*limit - i+1; | warning: unnecessary parentheses around assigned value --> src/main.rs:88:34 | 88 | ... res*=(i-1); | ^ ^ | help: remove these parentheses | 88 - res*=(i-1); 88 + res*=i-1; | warning: unnecessary parentheses around assigned value --> src/main.rs:91:34 | 91 | ... res*=(2*limit - n/i+1); | ^ ^ | help: remove these parentheses | 91 - res*=(2*limit - n/i+1); 91 + res*=2*limit - n/i+1; | warning: unnecessary parentheses around assigned value --> src/main.rs:93:34 | 93 | ... res*=(n/i-1); | ^ ^ | help: remove these parentheses | 93 - res*=(n/i-1); 93 + res*=n/i-1; | warning: value assigned to `ans` is never read --> src/main.rs:109:13 | 109 | 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); } }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); }