結果
問題 |
No.467 隠されていたゲーム
|
ユーザー |
|
提出日時 | 2019-10-12 15:37:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 562 ms |
コンパイル使用メモリ | 67,176 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 01:06:50 |
合計ジャッジ時間 | 1,270 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 31 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N; long D[15]; long X,Y; long f(long d) { if(X%d==0&&Y%d==0) { return max(X/d,Y/d); } else if(X%d==0) { if(X>=d)return max(X/d,Y/d+1); else return max(2L,Y/d+1); } else if(Y%d==0) { if(Y>=d)return max(X/d+1,Y/d); else return max(X/d+1,2L); } else { if(X>=d&&Y>=d)return max(X/d+1,Y/d+1); else if(X>=d)return X/d+1; else if(Y>=d)return Y/d+1; else return 2; } } main() { cin>>N; for(int i=0;i<N;i++)cin>>D[i]; cin>>X>>Y; if(X<0)X=-X; if(Y<0)Y=-Y; long ans=9e18; for(int i=0;i<N;i++)ans=min(ans,f(D[i])); cout<<ans<<endl; }