結果

問題 No.61 リベリオン
ユーザー te-shte-sh
提出日時 2017-01-20 16:23:48
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 905 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 96,456 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 00:46:50
合計ジャッジ時間 2,263 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 1 ms
4,380 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 += ux;
      bx = (bx < 0 ? bx + w2 : bx) % w2;
      by += uy;
      by = (by < 0 ? by + h2 : by) % 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