結果
問題 |
No.186 中華風 (Easy)
|
ユーザー |
|
提出日時 | 2020-03-01 05:37:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 333 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 64,616 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 18:37:58 |
合計ジャッジ時間 | 1,513 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; long gcd(long a,long b){return b?gcd(b,a%b):a;} main() { long X,Y; cin>>X>>Y; if(X==0)X=Y; for(int _=0;_<2;_++) { long x,y;cin>>x>>y; for(int i=0;i<y;i++) { if(X%y==x)break; X+=Y; } if(X%y!=x) { cout<<-1<<endl; return 0; } Y=Y/gcd(Y,y)*y; } cout<<X<<endl; }