結果
| 問題 |
No.642 Two Operations No.1
|
| コンテスト | |
| ユーザー |
vrjfsyi
|
| 提出日時 | 2018-04-06 23:04:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 708 bytes |
| コンパイル時間 | 565 ms |
| コンパイル使用メモリ | 72,952 KB |
| 実行使用メモリ | 817,548 KB |
| 最終ジャッジ日時 | 2024-06-26 10:51:39 |
| 合計ジャッジ時間 | 3,639 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 MLE * 1 -- * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>
using namespace std;
int main() {
long N;
cin >> N;
queue<pair<long, long>> q;
q.push(make_pair(1, 0));
long count = -1;
while (!q.empty()) {
auto p = q.front();
q.pop();
if (p.first == N) {
count = p.second;
break;
}
if ((p.first - 1) >= 1) {
q.push(make_pair(p.first - 1, p.second + 1));
}
if ((p.first * 2) <= 1e9) {
q.push(make_pair(p.first * 2, p.second + 1));
}
}
cout << count << "\n";
}
vrjfsyi