結果
問題 | No.2426 Select Plus or Minus |
ユーザー |
|
提出日時 | 2024-11-12 14:54:00 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 383 bytes |
コンパイル時間 | 1,020 ms |
コンパイル使用メモリ | 68,352 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-12 14:54:04 |
合計ジャッジ時間 | 2,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <iostream>#include <cstdint>using namespace std;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);uint64_t N;cin >> N;string c;while (N != 1){if (!(N & 1)) c.push_back('/'), N >>= 1;else if (((N * 3) & 3) == 3) c.push_back('+'), N = N * 3 + 1;else c.push_back('-'), N = N * 3 - 1;}cout << c.size() << '\n' << c << '\n';return 0;}