結果

問題 No.61 リベリオン
ユーザー h_nosonh_noson
提出日時 2016-03-19 13:09:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 1,128 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 60,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 17:19:53
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 109 ms
5,376 KB
testcase_04 AC 109 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int gcd(int a, int b) {
    return (b == 0) ? a : gcd(b,a%b);
}

int main() {
    int i, j, q;
    cin >> q;
    rep (i,q) {
        int w, h, d, mx, my, hx, hy, vx, vy;
        int x, y, gcdxy;
        cin >> w >> h >> d >> mx >> my >> hx >> hy >> vx >> vy;
        x = hx; y = hy;
        gcdxy = gcd(abs(vx),abs(vy));
        vx = vx / gcdxy;
        vy = vy / gcdxy;
        for (j = -1; j < min(1000,d*gcdxy) && (x != mx || y != my); j++) {
            x += vx + 30*w; y += vy + 30*h;
            x %= 2*w; y %= 2*h;
            if (x > w) {
                x = 2*w - x;
                vx = -vx;
            }
            if (y > h) {
                y = 2*h - y;
                vy = -vy;
            }
        }
        if (j != min(1000,d*gcdxy))
            cout << "Hit" << endl;
        else
            cout << "Miss" << endl;
    }
    return 0;
}
0