結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-21 00:15:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,424 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 91,560 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 21:30:48 |
| 合計ジャッジ時間 | 1,273 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 2 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
int gcd(int a, int b){
while(b != 0){
int tmp = a % b;
a = b;
b = tmp;
}
return a;
}
bool solve()
{
int w, h, n, mx, my, x, y, vx, vy;
cin >> w >> h >> n >> mx >> my >> x >> y >> vx >> vy;
int g = gcd(abs(vx), abs(vy));
n *= g;
vx /= g;
vy /= g;
n = min(n, (w + 1) * (h + 1));
while(--n >= 0){
x += vx;
y += vy;
while((vx < 0 && x <= 0) || (vx > 0 && x >= w)){
if(x <= 0)
x = -x;
else
x = 2 * w - x;
vx *= -1;
}
while((vy < 0 && y <= 0) || (vy > 0 && y >= h)){
if(y <= 0)
y = -y;
else
y = 2 * h - y;
vy *= -1;
}
if(x == mx && y == my)
return true;
}
return false;
}
int main()
{
int q;
cin >> q;
while(--q >= 0){
if(solve())
cout << "Hit" << endl;
else
cout << "Miss" << endl;
}
return 0;
}