結果
| 問題 | No.643 Two Operations No.2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-02 22:01:01 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 375 bytes |
| 記録 | |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 76,124 KB |
| 実行使用メモリ | 9,600 KB |
| 最終ジャッジ日時 | 2026-06-04 18:34:26 |
| 合計ジャッジ時間 | 4,201 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 1 TLE * 1 -- * 6 |
ソースコード
#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;
}