結果
| 問題 | No.321 (P,Q)-サンタと街の子供たち |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-22 14:21:03 |
| 言語 | D (dmd 2.113.0) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 787 bytes |
| 記録 | |
| コンパイル時間 | 2,869 ms |
| コンパイル使用メモリ | 194,044 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-10-22 14:21:10 |
| 合計ジャッジ時間 | 6,632 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 38 WA * 3 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(3011): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
private typeof(T.init % T.init) gcdImpl(T)(T a, T b)
^
ソースコード
module main;
// http://rsujskf.s602.xrea.com/?yukicoder_321 より
// 2次元グリッド
import std;
void main()
{
// 入力
int P, Q;
readln.chomp.formattedRead("%d %d", P, Q);
int N = readln.chomp.to!int;
alias T = Tuple!(int, "x", int, "y");
auto pts = new T[](N);
foreach (ref p; pts)
readln.chomp.formattedRead("%d %d", p.x, p.y);
// 答えの計算と出力
if (P == 0) {
if (Q == 0) {
writeln(pts.count(T(0, 0)));
return;
}
writeln(pts.count!(a => a.x % Q == 0 && a.y % Q == 0));
return;
}
if (Q == 0) {
writeln(pts.count!(a => a.x % P == 0 && a.y % P == 0));
return;
}
int g = gcd(P, Q);
P /= g, Q /= g;
int ans = 0;
foreach (p; pts) {
if (p.x % g || p.y % g)
continue;
ans += (P + Q) % 2 || (p.x + p.y) % 2 == 0;
}
writeln(ans);
}