結果
| 問題 | No.1200 お菓子配り-3 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-04 22:31:33 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,296 bytes |
| コンパイル時間 | 13,221 ms |
| コンパイル使用メモリ | 376,872 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 12:15:00 |
| 合計ジャッジ時間 | 23,661 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 WA * 2 |
ソースコード
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);
}
}