結果
問題 |
No.186 中華風 (Easy)
|
ユーザー |
![]() |
提出日時 | 2016-03-28 01:38:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 955 bytes |
コンパイル時間 | 830 ms |
コンパイル使用メモリ | 73,652 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-02 05:40:24 |
合計ジャッジ時間 | 1,659 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <limits.h> #include <time.h> #include <string> #include <string.h> #include <sstream> #include <set> #include <cstdio> #include <cstdlib> #include <cmath> #include <stack> #include <queue> using namespace std; typedef long long ll; ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } ll lcm(ll a, ll b){ return a*b / gcd(a, b); } int main(){ ll x1, y1, x2, y2, x3, y3; cin >> x1 >> y1; cin >> x2 >> y2; cin >> x3 >> y3; ll n1, n2; bool success = false; ll l = lcm(y1, y2); for(int i = 0; i <= y2 && !success; i++){ n1 = x1 + y1 * i; if (n1 % y2 == x2) { for(int j = 0; j <= y3 && !success; j++){ n2 = n1 + l * j; if (n2 % y3 == x3) { success = true; break; } } } } if (success) { cout << n2 << endl; } else { cout << -1 << endl; } return 0; }