結果

問題 No.61 リベリオン
ユーザー chaemonchaemon
提出日時 2014-11-10 00:01:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 2,309 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 74,464 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 02:53:08
合計ジャッジ時間 2,293 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ gcd and inverse
Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
	Int g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
Int invMod(Int a, Int m) {
	Int x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0; // unsolvable
}
//}}}

int Q;
int W,H,D,Mx,My,Hx,Hy,Vx,Vy;

int main(){
	cin>>Q;
	REP(i,Q){
		cin>>W>>H>>D>>Mx>>My>>Hx>>Hy>>Vx>>Vy;
		int g = abs(gcd(Vx,Vy));
		Vx/=g;Vy/=g;
		bool found = false;
		if(D>=10000)D=10000;
		REP(i,100){
			REP(j,100){
				int x,y;
				if(i%2==0)x=W*i+Mx;
				else x = W*i+W-Mx;
				if(j%2==0)y=H*j+My;
				else y = H*j+H-My;
				if(x<Hx and y<Hy)continue;
				if((x-Hx)%Vx==0 and (y-Hy)%Vy==0 and (x-Hx)*Vy==(y-Hy)*Vx){
					int t = (x-Hx)/Vx;
					if(0<=t and t<=D)found=true;
				}
			}
		}
		if(found){
			cout<<"Hit"<<endl;
		}else{
			cout<<"Miss"<<endl;
		}
	}
	
}
0