Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
596_D. Wilbur and Trees
Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct. The trees are equal, i.e. each tree has height h....
2
10
#include <bits/stdc++.h> using namespace std; const int N = 2020; double dp[N][N][2][2]; int pos[N], nextPos[N], prevPos[N]; int n, height; double p; double go(int l, int r, bool lastL, bool lastR) { if (l > r) return 0.0; double& ret = dp[l][r][lastL][lastR]; if (ret == ret) return ret; ret = 0.0; { doub...
CPP
596_D. Wilbur and Trees
Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct. The trees are equal, i.e. each tree has height h....
2
10
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 5, M = 1e9 + 7; int n, h, pos[N], LeBoss[N], RiBoss[N]; double p, dp[N][N][2][2]; int le[N], ri[N]; int vis[N][N][2][2]; int findLeBoss(int x) { if (LeBoss[x] == x) return x; return LeBoss[x] = findLeBoss(LeBoss[x]); } int findRiBoss(int x) { if (R...
CPP
596_D. Wilbur and Trees
Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct. The trees are equal, i.e. each tree has height h....
2
10
#include <bits/stdc++.h> using namespace std; const int N = 2010; int n, h, first[N], l[N], r[N]; double p, q, f[N][N][2][2]; bool check[N][N][2][2]; void read() { cin >> n >> h >> p; for (int i = 1; i <= n; i++) cin >> first[i]; } void init() { sort(first + 1, first + n + 1); first[0] = first[1] - h; first[n...
CPP
596_D. Wilbur and Trees
Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down. There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct. The trees are equal, i.e. each tree has height h....
2
10
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:100000000") using namespace std; double p, q; int n, h; int mas[100100]; double dp[2020][2020][2][2]; double solve(int l, int r, int n1 = 0, int n2 = 1) { if (r < l) return 0.0; if (dp[l][r][n1][n2] > -1) return dp[l][r][n1][n2]; if (n1 == 1) { if (mas[...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def answer(n): x=[] while(n!=0): temp=n%2 n//=2 x.append(temp) for i in reversed(range(len(x))): if x[i]==1: print(i+1,end=' ') n=int(input()) answer(n)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i = n, j = 1, output[17] = {-1}, output_l = 0; while (i > 0) { if (i % 2 == 1) { output[output_l] = j; output_l++; } i /= 2; j++; } for (int i = output_l - 1; i > -1; i--) { cout << output[i] << "...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def get(k): find = False for i in range(len(k)): if k[i] == 0: k[i] = 1 break else: k[i] = 0 else: k.append(1) return k n = int(input()) k = [] for i in range(n): k = get(k) for i in range(len(k) - 1, -1, -1): if k[i]: print(i...
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; public class Forces_618A { public static void main(String args[]) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamRe...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; stack<long long> s; for (long long i = 0; i < n; i++) { if ((s.empty()) || ((s.top()) != 1)) { s.push(1); } else { long long cur = 1; while (!s.empty()...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) bit=bin(n)[2:] v=[] l=len(bit) for i in range(l): if bit[l-i-1]=='1': v.append(i+1) v.reverse() print(' '.join(map(str,v)))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; import java.io.*; public class A { FastScanner in; PrintWriter out; public void solve() throws IOException { int n = in.nextInt(); List<Integer> list = new ArrayList<>(); int c = 0; while (n > 0) { c++; if (n % 2 == 1) list.add(c)...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
// package codeforces.wunderfund2016; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; /** * Created by hama_du on 2016/01/30. */ public class Main { public sta...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.regex.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("outp...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; #pragma GCC diagnostic ignored "-Wunused-result" int main() { ios_base::sync_with_stdio(false); vector<int> ans; int n; cin >> n; while (n--) { ans.push_back(1); int index = ans.size() - 1; while (index > 0) { if (ans[index] == ans[index - 1]) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n != 0) { int a = log2(n); cout << a + 1 << " "; int b = pow(2, a); n = n % b; } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def bina(x): ret = "" while(x>0): ret = str(x%2)+ret x = x//2 return ret a = int(input()) b = bina(a) l = len(b) print(l-b.find("1"), end="") for i in range(b.find("1")+1, l): if b[i:i+1] == "1": print(" "+str(l-i), end = "")
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
from sys import stdout n=input() D=[] x=0 while n>0: D.append(n%2) n=n/2 y=len(D)-1 while y>=0: if D[y]==1: stdout.write(str(y+1)) stdout.write(" ") y=y-1
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) l = [] for _ in range(n): l.append(1) while len(l) > 1 and l[-1] == l[-2]: l[-2] += 1 l.pop() print(*l , sep = ' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) x = bin(n)[2:] ll = len(x) res = [] for i in range(ll): if x[i] == "1": res.append(str(ll - i)) print(" ".join(res))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
print(" ".join([str(v+1)for v,k in enumerate(bin(int(input()))[::-1])if k=="1"][::-1]))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int MAX_N = 505; const int MAX_M = 2020; const int MAX_T = 24; const int INF = 0x3f3f3f3f; vector<int> state; void compress() { int s = state.size(); if (s < 2) return; while (state.size() > 1 && (state[state.size() - 1] == state[state.size() - 2])) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector<long long> a; long long n, v1, v2; cin >> n; for (long long i = 1; i <= n; i++) { a.push_back(1); while (a....
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const int MOD = 1e9 + 7; const double pi = acos(-1.0); const double eps = 1e-6; const int maxn = 1e3 + 5; const int maxm = 1e6 + 5; const int dx[...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; stack<int> st; scanf("%d", &n); int i = 1; while (n) { if (n % 2) { st.push(i); } i++; n /= 2; } while (st.size()) { printf("%d ", st.top()); st.pop(); } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int a[1000000]; int main(void) { int n, i, j, k, q; while (~scanf("%d", &k)) { int z = 0; memset(a, 0, sizeof(a)); while (k) { a[z] = 1; while (z > 0) { if (a[z] == a[z - 1]) { z--; a[z]++; } if (a[z] !...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n, m, k, i, g; scanf("%d", &n); v.push_back(1); for (i = 1; i < n; i++) { g = 1; while (v.size() > 0) { k = v.size(); if (v[k - 1] != g) break; v.pop_back(); g++; } v.push_back(g); } for (i ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; long fact(long n) { long long k = 1; for (int i = 1; i <= n; i++) k *= i; return k; } long nod(long n, long m) { if (n == 0 || m == 0) return n + m; if (n > m) return nod(n % m, m); else return nod(n, m % n); } long ot, g, n, j, ss, k, maxl, ctn, typ, q,...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6; vector<int> a; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; int k = 0; int curr = -1; for (k = 0; k < n; k++) { a.push_back(1); curr++; if (k == 0) continue; while (1) { if (a[curr] == a[curr - 1]) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.*; public class A618 { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); int n = input.nextInt(); for(int i = 30; i>=0; i--) { if((n & (1<<i)) > 0) out.print((i+1)+" "); } out.close(); } public s...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int64_t MOD = 1E9 + 7; template <class T, class U> void smin(T& a, const U& b) { if (a > b) a = b; } template <class T, class U> void smax(T& a, const U& b) { if (a < b) a = b; } string getstr() { char s[200001]; scanf("%s", s); return s; } int main() { in...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) s = [1] for i in range(n - 1): s.append(1) while len(s) > 1 and s[-2] == s[-1]: s = s[:-2] + [1 + s[-1]] print(*s)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; inline namespace Infinity { const char CR = '\n'; inline void write(const int n) { printf("%d", n); } inline void write(const unsigned n) { printf("%u", n); } inline void write(const long long n) { cout << n; } inline void write(const unsigned long long n) { cout << n; } in...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.ArrayList; import java.util.Scanner; /** * Created by Сергей on 09.02.2016. */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int amount_Worms = in.nextInt(); int number_Of_Matches = 1; ArrayList<Integer> arr = ne...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class A { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); List<Integer> ans = new ArrayList<>(); int n = scanner.nextInt(); while (n > 0) { int t = 1; int x = 1; ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; stack<int> st; vector<int> ans; int main() { int n, now; scanf("%d", &n); while (n) { now = 1; n--; while (!st.empty() && st.top() == now) { st.pop(); now++; } st.push(now); } while (!st.empty()) { ans.push_back(st.top()); s...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#!/usr/bin/python def ir(): return int(raw_input()) n = ir() s = [] for i in range(n): c = 1 while s and s[-1]==c: s.pop() c += 1 s.append(c) print ' '.join(map(str, s))
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
//Slime.java import java.util.*; public class Slime{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int setIndex = 2; int remainder = 0; int numSet = N; int rVal = 1; Stack<Integer> ans = new Stack<Integer>(); do{ ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
from collections import deque n = input() s = deque() for i in range(n): s.append(1) while len(s) > 1 and s[len(s)-1] == s[len(s)-2]: s.pop() s.append(s.pop() + 1) print ' '.join(map(str, s))
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2016 varshit <varshit@varshit-Lenovo> # # Distributed under terms of the MIT license. """ """ x=input() a=[1 for i in range(x)] count=[] for i in range(x): count.append(a[i]) length=len(count) if(length>1): while(coun...
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) for i in range(20,-1,-1): if 2**i<=n: print(i+1,end=" ") n-=2**i # Made By Mostafa_Khaled
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> int n, i, A[100001]; int log(int x, int sayac) { if (x < 2) { return sayac; } return log(x / 2, sayac + 1); ; } int fpow(int a, int b) { if (b == 0) return 1; int x = fpow(a, b / 2); x = x * x; if (b % 2) x = x * a; return x; } int main() { scanf("%d", &n); while (1) {...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) b = str(bin(n)) i = b.index("1") while i < len(b): if b[i] == "1": print len(b) - i, i += 1
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) ans = 1 while n != 0: ans = ans * 10 + n % 2 n = n // 2 #print(ans) ans = str(ans)[1:] #print(ans) for i in range(len(ans) - 1, -1, -1): if ans[i] == '1': print(i + 1, end = ' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; long n; long prov(long x) { long c = 1; long st = 0; while (c < x) { c *= 2; st++; } if (c == x) return st + 1; if (st != 0) return st; return 1; } int main() { cin >> n; if (n == 1) { cout << 1; return 0; } if (n == 2) { cout << 2;...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int n, i, ys, l; int a[1002] = {0}; int main() { cin >> n; for (l = 0; n; l++) { ys = n & 1; a[l] = ys; n >>= 1; } for (l--; l >= 0; l--) if (a[l]) printf("%d ", l + 1); return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s = ""; while (n != 0) { if (n & 1) s += '1'; else s += '0'; n /= 2; } for (int i = s.size(); i >= 0; i--) if (s[i] == '1') cout << i + 1 << " "; cout << endl; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) s = bin(n)[2:] for i in range(len(s)): if s[i] == '1': print(len(s) - i, end = ' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const long long linf = 1000000000000000043; const int inf = 1000000043; void pause(bool a = true) {} template <class T> inline T prod(pair<T, T> a, pair<T, T> b, pair<T, T> c = make_pair(0, 0)) { return (a.first - c.first) * (b.second - c.second) - (a.second - c....
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.Scanner; public class a618 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); for(int i = (int)Math.round((Math.log(Integer.highestOneBit(n))/Math.log(2))); i >=0;i--){ if((n&(1<<i))!=0){ System.out....
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<int> h; cin >> n; while (n) { h.push_back(1); while (h.size() > 1 && h[h.size() - 1] == h[h.size() - 2]) { h.erase(h.begin() + h.size() - 1, h.end()); h[h.size() - 1]++; } n--; } for (int i = 0; i < h.size()...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int pow2(int n) { int R = 1; for (int i = 0; i < n; ++i) R *= 2; return R; } int main() { int n, m; cin >> n; while (n) { m = log2(n); cout << m + 1 << " "; n -= pow2(m); } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int n, a[maxn]; int main() { scanf("%d", &n); int cur = 0; a[0] = 1; for (int i = 1; i < n; ++i) { a[++cur] = 1; while (cur != 0 && a[cur] == a[cur - 1]) { a[cur - 1]++; --cur; } } for (int i = 0; i <= cur; +...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=input() b=30 while b >= 0: if 1<<b & n: print b+1, b -= 1
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; public class A{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), s = 0; int[] a = new int[n]; for (int i = 0; i < n; ++ i) { a[s++] = 1; int j = s-1; while (j > 0 && a[j] == a[j-1]) { a[j-1] += 1; a[j] = 0; j = --s-1; ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long lt[34], n, j, i; lt[0] = 1; cin >> n; for (int i = 1; i <= 30; i++) lt[i] = lt[i - 1] * 2; j = 30; while (n != 0) { for (i = j; i >= 0; i--) if (n >= lt[i]) { n -= lt[i]; cout << i + 1 << ' '; } j = i; } }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.*; public class prog { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 1...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = LLONG_MAX; const long long ninf = LLONG_MIN; const double eps = 1e-10; const long long N = 1000005; const long long LOGN = log2(N); int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<int> arr; ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int power(int a) { int i, p = 1; for (i = 1; i <= a; i++) p *= 2; return p; } int main() { int n, l, z = 0; scanf("%d", &n); while (n) { l = log2l(n); printf("%d ", l + 1); n %= power(l); } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; long long int a[1000001]; int main() { long long int n; cin >> n; int k = 0; while (n--) { a[k] = 1; int j = k; while (a[j] == a[j - 1]) { a[j - 1] = a[j - 1] + 1; a[j] = 0; j--; } k = ++j; int i = 0; } int i = 0; whil...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) a=[] for i in range(n): a.append(1) while len(a)>1: if a[len(a)-2]==a[len(a)-1]: a[len(a)-2]=a[len(a)-1]+1 del(a[len(a)-1]) else: break for i in range(len(a)): print(a[i],end=" ")
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String[] args)throws IOException{ PrintWriter pw = new PrintWriter(System.out); InputReader in = new InputReader(System.in); int n = in.nextInt(); int x = (int)(Math.log10(n)/Math.log10(2)); x+=1; ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; public class CF_618A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); LinkedList<Integer> a = new LinkedList<Integer>(); int c = 0; if (n > 2) { while (n-- > 0) { a.add(1); while (c > 0 && a.get(c) == a.get(c-1)) { int t...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#k=int(input()) #n,m=map(int,input().split()) #a=list(map(int,input().split())) #b=list(map(int,input().split())) n=int(input()) a=[0]*10000000 cnt=-1 while(n): r=n%2 n//=2 cnt+=1 a[cnt]=r for i in range(cnt+1): if a[cnt-i]==1: print(cnt-i+1,end=' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { v.push_back(1); while (v.size() >= 2) { if (v.back() == v[v.size() - 2]) { v.pop_back(); v.back()++; continue; } break; } } for...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author Nikhil Pathania */ public class Slime { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int test=I...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def slimes(n): # k, cnt, ans = 1, 1, [] # while(k <= n): # k = k * 2 # cnt += 1 # while(n != 0): # if(k > n): # k = k / 2 # cnt -= 1 # else: # ans.append(str(cnt)) # n = n - k # return ans cnt, ans = 1, "" while(n > 0): if(n % 2 == 1): ans = " " + str(cnt) + ans cnt += 1 n = n // 2 ...
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int arr[100008]; int main() { int i, j, k, t, n, m, a, b, c, x, y, z, cs; int cur = 0; cin >> n; for (i = 1; i <= n; i++) { arr[++cur] = 1; while (arr[cur - 1] == arr[cur]) { arr[cur - 1] = arr[cur] + 1; cur--; } } for (i = 1; i <= cur; i...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v; int i = 1; while (n != 0) { if (n % 2 == 1) { v.push_back(i); } n = n / 2; i++; } for (int i = v.size() - 1; i >= 0; i--) cout << v[i] << ' '; return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import math n = int(input()) s = '' while n > 0: tmp = int(math.log(n) / math.log(2) + 1) s = s + str(tmp) + ' ' n -= pow(2, tmp - 1) print(s)
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); ArrayList<Integer> array = new ArrayList<Integer>(); for(int i = 0;i<a;i++) { array.add(1); } for(int v =0;v < array.size()*10;v++) { for(int c = 0 ; c< array.size()-...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; void go(int n, int r) { r++; if (n / 2 == 0) cout << r << " "; else { go(n / 2, r); if (n % 2 == 1) { cout << r << " "; } } } int main() { int n; cin >> n; go(n, 0); }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; import java.io.*; import java.math.*; import java.text.*; public class Slimes { public static void solve(int n, int val, LinkedList<Integer> sofar) { if (n == 0) { print(sofar); } else if (n == 1) { sofar.push(val); print(sofar); } else { if (n % 2 == 1) { sofar.push(val); ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); try { ArrayList<String> buffer = new Arr...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int n = Integer....
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int a[1000]; int main() { int n, x, i = 0, j = 0, p, cnt; cin >> n; x = n; while (x != 0) { p = 1, cnt = 0; while (p <= x) { p = p * 2; cnt++; } a[i] = cnt; x = x - p / 2; i++; } for (j = 0; j < i; j++) cout << a[j] << " "; ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int nm[32]; int main() { int n; nm[0] = 1; for (int i = 1; i <= 16; i++) { nm[i] = nm[i - 1] * 2; } while (~scanf("%d", &n)) { while (n) { for (int i = 0; i <= 16; i++) { if (nm[i] == n) { printf("%d\n", i + 1); n -= nm[i]...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.ArrayList; import java.util.Scanner; public class Tester { public static void main(String args[]){ Scanner s1=new Scanner(System.in); int n=s1.nextInt(); ArrayList<Integer> l1=new ArrayList<Integer>(); int pre=1; while(n!=0) { if(n%2==0) { n=n/2; pre++; } else { ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) ans = [] for _ in range(n): ans.append(1) while len(ans) >= 2 and ans[-1] == ans[-2]: ans[-2] += 1 ans.pop() print(*ans)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using lli = long long int; using namespace std; bool isprime(lli n); lli gcd(lli a, lli b); lli lcm(lli n, lli m); lli fact(lli n); double dgr(double a); int fixMod(int a, int b); long long ncr(int n, int r); void fast(); lli maxSubArraySum(lli a[], lli size); lli compute(lli h, lli n, int cur)...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 0x3fffffff; int main() { int N, ans = 0;...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#n, k = map(int, input().split(" ")) # read multiple integers into different variables #L = [int(x) for x in input().split()] # read multiple integers into a list #print(' '.join(map(str, L))) # print multiple integers in one line n = int(input()) L = [] r = 1 ct = 1 while n >= r : if (n ...
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> int a[100100] = {1}; int main() { int i, j, n; scanf("%d", &n); int size = 1; n--; while (n--) { int c = 1; if (a[size - 1] == c) { while (size - 1 >= 0 && a[size - 1] == c) { a[size - 1]++; c = a[size - 1]; size--; } size++; } els...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> v; for (int i = 1; i <= n; ++i) { v.push_back(1); while (v.size() > 1 && v.back() == v[v.size() - 2]) { v.pop_back(); ++v.back(); } } for (int i = 0; i < v.size(); ++i) printf("%d ", v[i]);...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
v = [] for i in range(int(input())): v.append(1) while (len(v) >= 2 and v[-1] == v[-2]): v.pop() v[-1] += 1 print(' '.join(map(str, v)))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { int n; Reader.init(System.in); n = Reader.nextInt(); int stepen = 0; while (...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int( raw_input() ) L = [] tot = 0 for i in range( 0, n ): L.append( 1 ) tot += 1 #print L, i, tot if tot >= 2: while tot >= 2 and L[tot-1] == L[tot-2]: L[tot-2] += 1 L.pop() tot -= 1 for i in range( 0, tot ): print L[i],
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(raw_input()) l=[] for i in xrange(n): l.append(1) while len(l)>1 and l[-1]==l[-2]: l[-2] += 1 l.pop() print " ".join([str(x) for x in l])
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.PrintWriter; import java.util.Scanner; import java.util.Stack; public class A { public static void main(String[] args) { Scanner sc= new Scanner (System.in); PrintWriter out= new PrintWriter(System.out); Stack<Integer> stack= new Stack<Integer>(); int n= sc.nextInt(); stack.push(1); for(in...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; import java.io.*; public class A { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); ArrayList<Integer> stack = new ArrayList<Integer>(); for(int x = 0; x < n; ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000005; int main() { int n; scanf("%d", &n); vector<int> res; int paso = 1; while (n) { if (n & 1) res.push_back(paso); paso++; n >>= 1; } for (int i = res.size() - 1; i >= 0; i--) printf("%d ", res[i]); printf("\n"); return 0...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int i, j, k, l, m, n, h; int a[100005]; int main() { scanf("%d", &n); h = 0; for (i = 1; i <= n; i++) { h++; a[h] = 1; for (; h > 0 && a[h] == a[h - 1];) { h--; a[h]++; } } for (i = 1; i <= h; i++) printf("%d ", a[i]); }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; long long int a[1000009]; int solve() { long long int i, j, k, x, y, z, m, n, u, v, l, r, t, mx, mn, p; cin >> n; if (n == 1) { cout << 1; return 0; } if (n == 2) { cout << 2; return 0; } k = 1; i = 0; while (n > 0) { if (n % 2 != 0) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class SlimeCombining implements Closeable{ BufferedReader reader = new BufferedReader(ne...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
N = int(raw_input()) stack = [] one, cnt = 1, 1 while cnt <= N: if len(stack) >= 1: num_to_cmp = one stack.append(num_to_cmp) while True and len(stack) >= 2: last_num = stack.pop() second_last_num = stack.pop() if last_num == second_last_num: ...
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 1; cin >> n; vector<int> vec; while (n) { if (n & 1) vec.push_back(i); n >>= 1; i++; } for (int i = (int)vec.size() - 1; i >= 0; i--) { cout << vec[i] << " "; } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) a=[] s=0 z=' ' if n==1: print(1) else: for i in range (n): a.append(1) n=n-1 for c in range (len(a)): if len(a)>1: if a[-1]==a[-2]: s=a[-2]+1 a.remove(a[-2]) a.remove(a[-1]) ...
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
x = int(raw_input()) x= bin(x)[2:] ans='' for i in range(len(x)): if(x[i]=='1'): ans+=(str(len(x)-i)+' ') print ans
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) if n == 1: print(1) elif n == 2: print(2) else: a = [2] for i in range(n-2): if len(a) == 1: a.append(1) else: if a[-1] != a[-2]: a.append(1) else: while len(a) > 1 and a[-1] == a[-2]: del(a[-1]); a[-1] += 1 while len(a) > 1 and a[...
PYTHON3