結果

問題 No.61 リベリオン
ユーザー h_nosonh_noson
提出日時 2016-03-18 17:16:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,101 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 61,340 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 16:59:10
合計ジャッジ時間 1,418 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
        cin >> w >> h >> d >> mx >> my >> hx >> hy >> vx >> vy;
        x = hx; y = hy;
        vx = vx / gcd(abs(vx),abs(vy));
        vy = vy / gcd(abs(vx),abs(vy));
        for (j = -1; j < min(1000,d) && (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))
            cout << "Hit" << endl;
        else
            cout << "Miss" << endl;
    }
    return 0;
}
0