結果
| 問題 |
No.2426 Select Plus or Minus
|
| コンテスト | |
| ユーザー |
kaityo_17
|
| 提出日時 | 2023-08-18 21:36:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,739 bytes |
| コンパイル時間 | 1,761 ms |
| コンパイル使用メモリ | 170,036 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 06:02:22 |
| 合計ジャッジ時間 | 3,782 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 35 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a; i < n; i++)
#define yes (cout << "Yes" << endl)
#define YES (cout << "YES" << endl)
#define no (cout << "No" << endl)
#define NO (cout << "NO" << endl)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vd = vector<double>;
using vl = vector<long long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using Graph = vector<vector<int>>;
const int mod = 998244353;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;
const string abc = "abcdefghijklmnopqrstuvwxyz";
int dight_sum(int t) {
int ans = 0;
while(t >= 10) {
ans += t % 10;
t /= 10;
}
ans += t;
return ans;
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
seen[v] = true; // v を訪問済にする
// v から行ける各頂点 next_v について
for (auto next_v : G[v]) {
if (seen[next_v]) continue; // next_v が探索済だったらスルー
dfs(G, next_v); // 再帰的に探索
}
}
ll gcd(ll a,ll b){
while(b!=0){
a%=b;
swap(a,b);
}
return a;
}
struct unionfind {
vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
unionfind (int N) : par(N) { //最初は全てが根であるとして初期化
for(int i = 0; i < N; i++) par[i] = i;
}
int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xとyの木を併合
int rx = root(x); //xの根をrx
int ry = root(y); //yの根をry
if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
}
bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
long long factorial(long long k) {
ll ans = 1;
rep(i,1,k + 1) {
ans *= i;
}
return ans;
}
int main () {
cout << fixed << setprecision(10);
ll n;
cin >> n;
int ans = 0;
string s = "";
while(n >= 2) {
if(n % 2 == 0) {
s += '/';
n /= 2;
ans++;
}
else {
s += '+';
n *= 3;
n++;
ans++;
}
}
cout << ans << endl;
cout << s << endl;
}
kaityo_17