結果
問題 |
No.186 中華風 (Easy)
|
ユーザー |
![]() |
提出日時 | 2015-04-21 09:08:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 788 bytes |
コンパイル時間 | 1,358 ms |
コンパイル使用メモリ | 157,560 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 19:01:35 |
合計ジャッジ時間 | 2,304 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 2 |
ソースコード
#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-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; }