結果
問題 | No.186 中華風 (Easy) |
ユーザー |
![]() |
提出日時 | 2015-04-21 09:09:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 1,250 ms |
コンパイル使用メモリ | 157,644 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 18:25:06 |
合計ジャッジ時間 | 1,981 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; ll X[3], Y[3]; int main() { cin.tie(0); ios::sync_with_stdio(false); for (int i = 0; i < 3; i++) { cin >> X[i] >> Y[i]; } for (ll i = 0; i < Y[1]; i++) { ll tmp = Y[0] * i + X[0]; if (tmp == 0) continue; if ((tmp-X[1]) % Y[1] == 0) { ll lcm = Y[0] / __gcd(Y[0], Y[1]) * Y[1]; for (ll j = 0; j < Y[2]; j++) { ll ans = tmp+j*lcm; if ((ans-X[2]) % Y[2] == 0) { cout << ans << endl; return 0; } } } } cout << -1 << endl; return 0; }