結果
問題 | No.643 Two Operations No.2 |
ユーザー |
|
提出日時 | 2018-02-02 22:10:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 847 ms |
コンパイル使用メモリ | 69,112 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 07:36:29 |
合計ジャッジ時間 | 1,307 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>using namespace std;int f(long long x, long long y, int c) {if (c == 9) return 1000;if (x == y) return 0;return min(f(y, x, c + 1), f(x + y, x - y, c + 1)) + 1;}int main() {long long x, y;cin >> x >> y;int ans = f(x, y, 0);if (ans >= 1000) {cout << -1 << endl;} else {cout << ans << endl;}}