結果
問題 |
No.2426 Select Plus or Minus
|
ユーザー |
![]() |
提出日時 | 2023-08-18 23:23:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 76,556 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-28 10:33:10 |
合計ジャッジ時間 | 2,709 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 35 WA * 6 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <queue> using namespace std; using ll = long long; using P = pair<int, int>; class Error1{}; string ans = ""; void dfs(ll x){ if(x == 1){ cout << ans.size() << endl; cout << ans << endl; throw Error1{}; } if(x%2 == 0){ ans += "/"; dfs(x/2); ans.pop_back(); }else{ if(x*3+1 <= 1000000000000000000){ ans += "+"; dfs(x*3+1); } ans.pop_back(); if(x*3-1 <= 1000000000000000000){ ans += "-"; dfs(x*3-1); } ans.pop_back(); } } int main(){ ll n; cin >> n; try{ dfs(n); }catch(Error1 &e){ }; return 0; }