結果
| 問題 |
No.2426 Select Plus or Minus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 21:03:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 390 bytes |
| コンパイル時間 | 515 ms |
| コンパイル使用メモリ | 66,768 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 04:42:06 |
| 合計ジャッジ時間 | 2,153 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
long N;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N;
string ans="";
while(N!=1)
{
if(N%2==0)
{
N/=2;
ans+='/';
}
else
{
if((N*3+1)%4==0)
{
N=N*3+1;
ans+='+';
}
else
{
N=N*3-1;
ans+='-';
}
}
}
cout<<ans.size()<<endl<<ans<<endl;
}