結果
| 問題 |
No.2426 Select Plus or Minus
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-28 20:47:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 528 bytes |
| コンパイル時間 | 1,840 ms |
| コンパイル使用メモリ | 166,212 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 08:39:09 |
| 合計ジャッジ時間 | 3,728 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
const ll inf = 1e18;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n;
cin>>n;
string ans;
while(n != 1){
if(n&1){
ll tmp = (n*3)/2;
if(tmp&1){
ans += "+/";
n = tmp+1;
}
else{
ans += "-/";
n = tmp;
}
}
else{
ans += '/';
n>>=1;
}
}
cout<<ans.size()<<'\n';
cout<<ans;
}