結果
問題 |
No.643 Two Operations No.2
|
ユーザー |
|
提出日時 | 2018-02-02 22:01:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 375 bytes |
コンパイル時間 | 567 ms |
コンパイル使用メモリ | 66,076 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2024-12-31 07:34:39 |
合計ジャッジ時間 | 7,254 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 3 TLE * 2 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int main() { int x, y; cin >> x >> y; if (abs(x - y) % 2 == 1) { cout << -1 << endl; return 0; } int ans = 0; while (x != y) { int x2 = x + y; int y2 = x - y; if (abs(x2 - y2) < abs(x - y)) { x = x2; y = y2; } else { swap(x, y); } ans++; } cout << ans << endl; return 0; }