結果
| 問題 | No.61 リベリオン | 
| コンテスト | |
| ユーザー |  h_noson | 
| 提出日時 | 2016-03-19 13:09:34 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 110 ms / 5,000 ms | 
| コード長 | 1,128 bytes | 
| コンパイル時間 | 598 ms | 
| コンパイル使用メモリ | 60,228 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-13 16:14:46 | 
| 合計ジャッジ時間 | 1,180 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 | 
ソースコード
#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;
}
            
            
            
        