結果
| 問題 | No.2426 Select Plus or Minus |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 21:07:11 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 551 bytes |
| 記録 | |
| コンパイル時間 | 1,519 ms |
| コンパイル使用メモリ | 179,276 KB |
| 実行使用メモリ | 993,008 KB |
| 最終ジャッジ日時 | 2026-05-22 08:17:27 |
| 合計ジャッジ時間 | 6,317 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 19 WA * 1 MLE * 1 -- * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
string ans;
while(n != 1){
if(n & 1){
if(n >= 1000000000){
ans += "-";
n = 3 * n - 1;
}else{
ans += "+";
n = 3 * n + 1;
}
}else{
ans += "/";
n /= 2;
}
}
//cerr << n << '\n';
cout << ans.size() << '\n';
cout << ans << '\n';
}