結果
| 問題 |
No.642 Two Operations No.1
|
| コンテスト | |
| ユーザー |
aaa
|
| 提出日時 | 2018-09-28 20:37:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 937 bytes |
| コンパイル時間 | 1,118 ms |
| コンパイル使用メモリ | 102,204 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 05:34:52 |
| 合計ジャッジ時間 | 1,703 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
using namespace std;
int main() {
int i, j, k;
long n, n2;
vector<long>re;
map<long, int>p1;
cin >> n;
n2 = n;
int cnt = 0;
while (true)
{
if (n == 1) break;
if (n % 2 == 0) {
n /= 2;
re.push_back(n);
cnt++;
}
else if (n % 2 == 1) {
n++;
cnt++;
n /= 2;
p1.insert(make_pair(n, 999));
re.push_back(n);
cnt++;
}
}
/*
for (i = re.size() - 1; i >= 0; i--) {
if (re[i] == n * 2 && p1[n*2]==999) {
n *= 2;
n--;
}
else if (re[i] == n * 2) {
n *= 2;
}
}
cout << "n->"<< n << endl;
*/
cout << cnt << endl;
getchar();
getchar();
return 0;
}
aaa