結果

問題 No.61 リベリオン
ユーザー te-shte-sh
提出日時 2017-01-20 16:26:27
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 869 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 96,576 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 00:47:16
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 54 ms
4,380 KB
testcase_04 AC 54 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions
import std.numeric;   // gcd

void main()
{
  auto q = readln.chomp.to!size_t;

  foreach (_1; q.iota) {
    auto rd = readln.split.to!(int[]);
    auto w = rd[0], h = rd[1], d = rd[2], mx = rd[3], my = rd[4];
    auto hx = rd[5], hy = rd[6], vx = rd[7], vy = rd[8];

    auto g = gcd(vx.abs, vy.abs), ux = vx / g, uy = vy / g;
    auto w2 = w * 2, h2 = h * 2;
    auto fij = new bool[][](h2, w2);

    auto bx = hx, by = hy;
    foreach (_2; (d * g).iota) {
      bx = ((bx + ux) % w2 + w2) % w2;
      by = ((by + uy) % h2 + h2) % h2;
      if (fij[by][bx]) break;
      fij[by][bx] = true;
    }

    auto rx = w2 - mx, ry = h2 - my;
    if (fij[my][mx] || fij[my][rx] || fij[ry][mx] || fij[ry][rx])
      writeln("Hit");
    else
      writeln("Miss");
  }
}
0