結果
問題 |
No.61 リベリオン
|
ユーザー |
![]() |
提出日時 | 2022-01-11 21:02:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 5,000 ms |
コード長 | 941 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 192,832 KB |
最終ジャッジ日時 | 2025-01-27 10:27:04 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&q); | ~~~~~^~~~~~~~~ main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d%d%d%d%d%d%d%d%d",&w,&h,&d,&mx,&my,&hx,&hy,&vx,&vy); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int q; int w,h,d,hx,hy,mx,my,vx,vy,g; int gcd(int a,int b){ if(a<0) a=-a; if(b<0) b=-b; int r; while(a){ r=b; b=a; a=r%a; } return b; } int main(){ scanf("%d",&q); for(int i=0;i<q;++i){ scanf("%d%d%d%d%d%d%d%d%d",&w,&h,&d,&mx,&my,&hx,&hy,&vx,&vy); g=gcd(vx,vy); vx/=g; vy/=g; d=min(1100ll,(long long)d*g); for(int j=0;j<d&&(hx!=mx||hy!=my);++j){ hx+=vx; hy+=vy; while(true){ if(hx<0){ hx=0-hx; vx=-vx; continue; } if(hx>w){ hx=2*w-hx; vx=-vx; continue; } if(hy<0){ hy=0-hy; vy=-vy; continue; } if(hy>h){ hy=2*h-hy; vy=-vy; continue; } break; } } if(hx==mx&&hy==my) printf("Hit\n"); else printf("Miss\n"); } return 0; }