結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
|
提出日時 | 2017-06-22 14:51:30 |
言語 | D (dmd 2.109.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 855 ms |
コンパイル使用メモリ | 107,088 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 20:26:27 |
合計ジャッジ時間 | 4,284 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 RE * 2 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.math; // math functions import std.numeric; // gcd, fft void main() { auto rd1 = readln.split.to!(long[]), p = rd1[0], q = rd1[1]; auto g1 = gcd(p, q); p /= g1; q /= g1; auto g2 = gcd((p ^^ 2 - q ^^ 2).abs, 2 * q); auto n = readln.chomp.to!size_t, r = 0; foreach (_; 0..n) { auto rd2 = readln.split.to!(long[]), x = rd2[0], y = rd2[1]; if (x % g1 != 0 || y % g1 != 0) continue; x /= g1; y /= g1; if (p == 0 && q == 0) { if (x == 0 && y == 0) ++r; } else if (p == 1 && q == 1) { if (x == y) ++r; } else if (p == 0 || q == 0 || g2 == 1) { ++r; } else { if ((q * y - p * x) % g2 == 0) ++r; } } writeln(r); }