結果

問題 No.2426 Select Plus or Minus
ユーザー elphe
提出日時 2024-11-12 14:54:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 68,492 KB
最終ジャッジ日時 2025-02-25 03:59:35
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint64_t N;
	cin >> N;

	string c;
	while (N != 1)
	{
		if (!(N & 1)) c.push_back('/'), N >>= 1;
		else if (((N * 3) & 3) == 3) c.push_back('+'), N = N * 3 + 1;
		else c.push_back('-'), N = N * 3 - 1;
	}

	cout << c.size() << '\n' << c << '\n';
	return 0;
}
0