結果
| 問題 | No.61 リベリオン | 
| コンテスト | |
| ユーザー |  goodbaton | 
| 提出日時 | 2015-08-06 00:37:45 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 15 ms / 5,000 ms | 
| コード長 | 1,482 bytes | 
| コンパイル時間 | 593 ms | 
| コンパイル使用メモリ | 72,500 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-13 16:14:40 | 
| 合計ジャッジ時間 | 1,027 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%d%d%d%d%d%d%d%d%d",&w,&h,&d,&mx,&my,&hx,&hy,&vx,&vy);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#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;
            vy=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;
}
            
            
            
        