結果
| 問題 |
No.61 リベリオン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-10 01:00:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,458 bytes |
| コンパイル時間 | 3,836 ms |
| コンパイル使用メモリ | 77,532 KB |
| 実行使用メモリ | 62,116 KB |
| 最終ジャッジ日時 | 2024-12-31 09:16:28 |
| 合計ジャッジ時間 | 6,402 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 2 WA * 2 |
ソースコード
import java.util.Scanner;
public class Main61 {
public static void main(String[] args) {
Main61 p = new Main61();
}
public Main61() {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
for(int i=0;i<q;i++){
int w = sc.nextInt();
int h = sc.nextInt();
int d = sc.nextInt();
int mx = sc.nextInt();
int my = sc.nextInt();
int hx = sc.nextInt();
int hy = sc.nextInt();
int vx = sc.nextInt();
int vy = sc.nextInt();
if(solve(w, h, d, mx, my, hx, hy, vx, vy)){
System.out.println("Hit");
}else{
System.out.println("Miss");
}
}
}
public boolean solve(int w, int h, int d, int mx, int my, int hx, int hy, int vx, int vy) {
int statex = 1;
int statey = 1;
if(vx <0){
vx = -vx;
statex = -1;
}
if(vy <0){
vy = -vy;
statey = -1;
}
int curx = hx;
int cury = hy;
int m = Math.min(d, 4*w*h);
for(int i=0;i<m;i++){
curx += statex * vx;
cury += statey * vy;
while(curx > w || curx < 0){
if(curx > w){
statex = -1;
curx = 2*w - curx;
}else if(curx < 0){
statex = 1;
curx = - curx;
}
}
while(cury >h || cury < 0){
if(cury > h){
statey = -1;
cury = 2*h - cury;
}else if(cury < 0){
statey = 1;
cury = - cury;
}
}
if(curx==mx && cury==my)
return true;
}
return false;
}
}