結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー te-shte-sh
提出日時 2017-06-22 14:51:30
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 767 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 95,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 14:43:23
合計ジャッジ時間 5,180 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 RE -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 60 ms
4,380 KB
testcase_15 AC 92 ms
4,380 KB
testcase_16 AC 39 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 46 ms
4,384 KB
testcase_19 AC 61 ms
4,380 KB
testcase_20 AC 92 ms
4,376 KB
testcase_21 AC 56 ms
4,376 KB
testcase_22 AC 17 ms
4,376 KB
testcase_23 AC 77 ms
4,376 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 51 ms
4,376 KB
testcase_26 AC 89 ms
4,376 KB
testcase_27 AC 66 ms
4,376 KB
testcase_28 AC 65 ms
4,380 KB
testcase_29 AC 93 ms
4,376 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 48 ms
4,380 KB
testcase_33 AC 46 ms
4,380 KB
testcase_34 AC 35 ms
4,380 KB
testcase_35 AC 72 ms
4,376 KB
testcase_36 AC 4 ms
4,376 KB
testcase_37 AC 57 ms
4,380 KB
testcase_38 AC 46 ms
4,380 KB
testcase_39 AC 15 ms
4,376 KB
testcase_40 AC 86 ms
4,380 KB
testcase_41 AC 25 ms
4,380 KB
testcase_42 AC 74 ms
4,380 KB
testcase_43 AC 38 ms
4,376 KB
testcase_44 AC 68 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

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);
}
0