結果

問題 No.1200 お菓子配り-3
ユーザー StrorkisStrorkis
提出日時 2020-08-29 00:28:37
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,488 bytes
コンパイル時間 13,296 ms
コンパイル使用メモリ 404,820 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 03:28:43
合計ジャッジ時間 20,115 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 6 ms
6,940 KB
testcase_10 AC 6 ms
6,944 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 45 ms
6,944 KB
testcase_13 AC 46 ms
6,940 KB
testcase_14 AC 47 ms
6,940 KB
testcase_15 AC 48 ms
6,940 KB
testcase_16 AC 46 ms
6,944 KB
testcase_17 AC 167 ms
6,944 KB
testcase_18 AC 241 ms
6,944 KB
testcase_19 AC 56 ms
6,940 KB
testcase_20 AC 462 ms
6,944 KB
testcase_21 AC 460 ms
6,944 KB
testcase_22 AC 544 ms
6,940 KB
testcase_23 AC 461 ms
6,940 KB
testcase_24 AC 454 ms
6,940 KB
testcase_25 AC 457 ms
6,944 KB
testcase_26 AC 461 ms
6,940 KB
testcase_27 AC 0 ms
6,940 KB
testcase_28 AC 364 ms
6,944 KB
testcase_29 AC 1,016 ms
6,944 KB
testcase_30 AC 1,018 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{BufRead, Write};

fn main () {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let s: usize = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    for _ in 0..s {
        let (x, y): (i64, i64) = {
            let mut buf = String::new();
            reader.read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse().unwrap(),
                iter.next().unwrap().parse().unwrap(),
            )
        };

        let p = x + y;
        let q = (x - y).abs();
        let mut ans = 0;
        let mut i = 1;
        while i * i <= q {
            if q % i > 0 {
                i += 1;
                continue;
            }
            let j = q / i;
            if p % (i + 2) == 0 {
                let u = p / (i + 2);
                let v = j;
                if u > v && (u + v) % 2 == 0 {
                    ans += 1;
                }
            }
            if i != j && p % (j + 2) == 0 {
                let u = p / (j + 2);
                let v = i;
                if u > v && (u + v) % 2 == 0 {
                    ans += 1;
                }
            }
            i += 1;
        }
        writeln!(writer, "{}", ans).unwrap();
    }
}
0