結果

問題 No.2426 Select Plus or Minus
ユーザー 👑 potato167
提出日時 2023-08-15 21:25:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 372 bytes
コンパイル時間 2,546 ms
コンパイル使用メモリ 193,168 KB
最終ジャッジ日時 2025-02-16 08:30:14
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(p) p.begin(),p.end()
#define rep(i,a,b) for(int i=(int)a;i<(int)b;i++)

int main(){
	ll N;
	cin>>N;
	string S;
	while(N!=1){
		if(N%2==0){
			N/=2;
			S+="/";
		}
		else{
			N*=3;
			N++;
			if(N%4==0) S+="+";
			else S+="-",N-=2;
		}
	}
	int ans=S.size();
	ans++;
	cout<<ans<<"\n"<<S<<"\n";
}
0