結果

問題 No.61 リベリオン
ユーザー goodbatongoodbaton
提出日時 2015-08-06 00:37:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,482 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 72,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 04:06:20
合計ジャッジ時間 1,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536

#define SIZE 101

int gcd(int a,int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

int main(){
    int q;
    
    scanf("%d",&q);
    
    for(int i=0;i<q;i++){
        int w,h,d,mx,my,hx,hy,vx,vy,G;
        bool visit[30][30]={0},ans=false,fx,fy;
        
        scanf("%d%d%d%d%d%d%d%d%d",&w,&h,&d,&mx,&my,&hx,&hy,&vx,&vy);
        
        if(vx<0){
            hx=w*2-hx;
            vx=abs(vx);
        }
        if(vy<0){
            hy=h*2-hy;
            vx=abs(vy);
        }
        
        G = gcd(vx,vy);
        
        vx/=G;
        vy/=G;
        d*=G;
        
        for(int i=0;i<d;i++){
            hx+=vx;
            hy+=vy;
            
            hx%=2*w;
            hy%=2*h;
            
            if(visit[hx][hy]) break;
            visit[hx][hy]=true;
            
            fx = mx==hx || hx==w*2-mx;
            fy = my==hy || hy==h*2-my;

            if(fx && fy){
                ans=true;
                break;
            }
        }
        
        if(ans)
            puts("Hit");
        else
            puts("Miss");
        
    }
    
    return 0;
}
0