結果

問題 No.2426 Select Plus or Minus
ユーザー achapiachapi
提出日時 2023-08-18 21:10:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 389 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 192,056 KB
最終ジャッジ日時 2025-02-16 09:19:50
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 35 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	unsigned long long N;
	cin >> N;
	string ans;
	while (N != 1){
		if (N % 2 == 0){
			N /= 2;
			ans.push_back('/');
		} else {
			if (N * 3 + 1 <= (long long) 1e18){
				N = N * 3 + 1;
				ans.push_back('+');
			} else {
				N = N * 3 - 1;
				ans.push_back('-');
			}
		}
	}
	cout << ans.size() << '\n';
	cout << ans << '\n';
}
0