結果

問題 No.864 四方演算
ユーザー kaito_tateyamakaito_tateyama
提出日時 2019-08-17 02:33:40
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,606 bytes
コンパイル時間 11,951 ms
コンパイル使用メモリ 165,964 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 23:03:36
合計ジャッジ時間 2,244 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 11 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 9 ms
4,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 9 ms
4,372 KB
testcase_08 AC 8 ms
4,372 KB
testcase_09 WA -
testcase_10 AC 5 ms
4,372 KB
testcase_11 AC 3 ms
4,372 KB
testcase_12 AC 9 ms
4,372 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 11 ms
4,372 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 9 ms
4,372 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 8 ms
4,372 KB
testcase_23 AC 1 ms
4,372 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,372 KB
testcase_28 AC 0 ms
4,372 KB
testcase_29 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::cmp::max`
  --> Main.rs:66:9
   |
66 |     use std::cmp::max;
   |         ^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `std::cmp::min`
  --> Main.rs:67:9
   |
67 |     use std::cmp::min;
   |         ^^^^^^^^^^^^^

warning: value assigned to `ans` is never read
  --> Main.rs:97:13
   |
97 |     let mut ans:i64 = 0;
   |             ^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: 3 warnings emitted

ソースコード

diff #

#[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;
    fn calc(a:i64,b:i64) -> i64 {
        if b>2*a {
            return 0;
        }
        if b<=a {
            return b-1;
        }
        2*a - b + 1
    }
    /// 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);
                    ans+=calc(limit, i) * calc(limit, n/i) * (if i==n/i {1}else{2});
                }
            }
        }
        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);
}
0