結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-13 16:22:23 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 5,000 ms |
| コード長 | 865 bytes |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 106,572 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 18:40:35 |
| 合計ジャッジ時間 | 1,400 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`
ソースコード
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; 0..q) {
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; 0..(d * g)) {
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");
}
}