結果

問題 No.1200 お菓子配り-3
ユーザー phsplsphspls
提出日時 2023-05-04 22:31:33
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,296 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 161,036 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-14 14:24:45
合計ジャッジ時間 13,540 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 71 ms
4,380 KB
testcase_13 AC 73 ms
4,380 KB
testcase_14 AC 73 ms
4,376 KB
testcase_15 AC 72 ms
4,376 KB
testcase_16 AC 71 ms
4,376 KB
testcase_17 AC 259 ms
4,376 KB
testcase_18 AC 370 ms
4,380 KB
testcase_19 AC 85 ms
4,376 KB
testcase_20 AC 709 ms
4,380 KB
testcase_21 AC 713 ms
4,380 KB
testcase_22 AC 847 ms
4,380 KB
testcase_23 AC 719 ms
4,376 KB
testcase_24 AC 712 ms
4,376 KB
testcase_25 AC 713 ms
4,380 KB
testcase_26 AC 715 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,163 ms
4,380 KB
testcase_29 AC 864 ms
4,376 KB
testcase_30 AC 863 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashSet;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: usize = s.trim().parse().unwrap();
    let queries = (0..s).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            let x = temp[0];
            let y = temp[1];
            (x.max(y), x.min(y))
        })
        .collect::<Vec<_>>();

    for &(x, y) in queries.iter() {
        let mut factors = HashSet::new();
        let mut i = 1;
        while i*i <= x+y {
            if (x+y) % i == 0 {
                if i >= 3 {
                    factors.insert(i);
                }
                let val = (x+y) / i;
                if val >= 3 {
                    factors.insert(val);
                }
            }
            i += 1;
        }
        let mut result = 0usize;
        for &p in factors.iter() {
            if (x-y) % (p-2) == 0 {
                let ax = (x+y) / p;
                let bx = (x-y) / (p-2);
                if ax > bx && (ax + bx) % 2 == 0{
                    result += 1;
                }
            }
        }
        println!("{}", result);
    }
}
0