結果
| 問題 |
No.2426 Select Plus or Minus
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-08-14 18:16:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 558 bytes |
| コンパイル時間 | 2,020 ms |
| コンパイル使用メモリ | 196,336 KB |
| 最終ジャッジ日時 | 2025-02-16 08:06:43 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
random_device seed_gen;
default_random_engine engine(seed_gen());
uniform_int_distribution<ll> dist(0, 1);
ll n; cin >> n;
vector<char> ans;
while(n > 1){
if (n % 2 == 0){
ans.push_back('/');
n /= 2;
}else{
if (dist(engine) == 0){
ans.push_back('+');
n = n * 3 + 1;
}else{
ans.push_back('-');
n = n * 3 - 1;
}
}
}
cout << (int)ans.size() << endl;
for (int i=0; i<(int)ans.size(); i++){
cout << ans[i] << " ";
}
cout << endl;
}
shobonvip