結果
問題 | No.2426 Select Plus or Minus |
ユーザー |
![]() |
提出日時 | 2023-08-22 14:32:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 195,116 KB |
最終ジャッジ日時 | 2025-02-16 12:15:41 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; cin>>n; vector<char> ANS; while(n>1){ if(n%2==0){ ANS.push_back('/'); n/=2; } else if((3*n)%4==1){ ANS.push_back('-'); n=3*n-1; } else{ ANS.push_back('+'); n=3*n+1; } } int a=ANS.size(); cout<<a<<endl; rep(i,a) cout<<ANS[i]; cout<<endl; return 0; }