結果

問題 No.2426 Select Plus or Minus
ユーザー stella1225stella1225
提出日時 2023-08-18 23:51:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 169,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 06:42:02
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,a,n) for (int i = a; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
int mod = 998244353;
int INF = 1001001001;
using pll = pair<int,int>;

int Flag=0;

//デフォルトでNoがでる
void yn(int Flag){
  if(Flag==1){
    cout<<"Yes"<<endl;
  }
  else if(Flag==0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Draw"<<endl;
  }
}

void cerrVec(vector<string> &V){
  int n=V.size();
  rep(i,0,n){
    for(auto x:V[i]){
      cerr<<x<<" ";
    }
    cerr<<endl;
  }
  cerr<<endl;
}

/*
  int H,W; cin>>H>>W;
  vector<vector<char>> C(H,vector<char> (W));
  rep(i,0,H) rep(j,0,W) cin>>C[i][j];
*/
int num(ll n){
  int res=0;
  while(n%2==0){
    res++;
    n/=2;
  }
  return res;
}

int main(){
  ll K; cin>>K;
  int cnt=0; string S;
  while(K!=1){
    if(K%2){
      K*=3;
      cerr<<K+1<<" "<<K-1<<endl;
      cerr<<num(K+1)<<" "<<num(K-1)<<endl;
      if(num(K+1)>num(K-1)){
        K++;
        S+="+";
      }
      else{
        K--;
        S+="-";
      }
    }
    else{
      K/=2;
      S+="/";
    }
    cnt++;
    cerr<<K<<endl;
  }
  cout<<cnt<<endl;
  cout<<S;
}

  
  
0