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
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()) print(' '.join(str(i + 1) for i in range(20, -1, -1) if (n & (1 << 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
n = int(input()) a = [] for i in range(n): a.append(1) while len(a) > 1 and a[len(a) - 1] == a[len(a) - 2]: a.pop() a[len(a) - 1] += 1 for i in a: print(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 math import log, floor x = int(input()) def fun(n): temp = floor(log(x, 2)) + 1 return int(temp) while x>0: temp2 = fun(x) print temp2, x = x-pow(2, temp2-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 = bin(input())[2:][::-1] for i in range(len(n)-1,-1,-1): if n[i] == '1' : print 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
import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.BufferedReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStreamReader; import java.io.IOException; /** * Built using CHelper plug-in * Actual soluti...
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.lang.Math; import java.util.*; public class ProblemA { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int nlog = (new Double(Math.log10(n) / Math.log10(2))).intValue() + 1; int[] result = new int[nlog...
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 N = 100000 + 100; int n; int a[100100], cnt = 0; int main() { scanf("%d", &n); while (n--) { a[++cnt] = 1; int now = cnt; while (now > 1 && a[now] == a[now - 1]) { a[now - 1] += 1; cnt--; now--; } } for (int i = 1; i <= cn...
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; int main() { cin >> n; for (int i = 20; i >= 0; i--) if ((n >> i) & 1) cout << i + 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,k = map(int,raw_input().split()) n = input() ans = '' power = 1 x = 1 while power <= n: power *= 2 x += 1 power /= 2 x -= 1 #print power,x while n > 0: if n >= power: n -= power ans+= (str(x) + ' ') power /= 2 x -= 1 print ans[:-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
# your code goes here n = input() s = bin(n)[2:] ss ='' s = s[::-1] c = 1 for i in s: if i=='1': ss = str(c) + ' ' + ss c+=1 print ss
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
__author__ = 'aste' def main(): n = int(raw_input()) res = [] v = 1 while n > 0: if n % 2 == 1: res.append(v) n /= 2 v += 1 print " ".join(["%d" % v for v in res[::-1]]) main()
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
from collections import deque if __name__ == '__main__': n = int(raw_input()) C = deque([1]) for _ in range(1, n): C.append(1) while len(C) >= 2 and C[-2] == C[-1]: a = C.pop() b = C.pop() C.append(a+1) print ' '.join(str(c) for c in C)
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 = [] i = 0 while N >> i: if (N >> i) & 1: ans.append(i+1) i += 1 print(*ans[::-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
n=int(input()) a=[] for j in range(n): a.append(1) if len(a)>1: for i in range(len(a)): if a[len(a)-2]==a[len(a)-1]: a[len(a)-2]=a[len(a)-2]+1 del a[len(a)-1] if len(a)==1: break print(*a)
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Inp...
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.*; import java.util.*; public class solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ArrayList<Integer>A = new ArrayList<>(); 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
#include <bits/stdc++.h> int main() { int n, i, k = 0, arr[100000]; scanf("%d", &n); for (i = 1; i <= n; i++) { arr[k++] = 1; while (k > 1 && arr[k - 1] == arr[k - 2]) { arr[k - 2]++; k--; } } for (i = 0; i < k; i++) printf("%d ", arr[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
n = raw_input() b = str(bin(int(n)))[2:] ans = [] b = b[::-1] for i,j in enumerate(b): if j == '1': ans.append(str(i+1)) ans = ans[::-1] final = ' '.join(ans) print final
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()) a = [] while n > 0: n -= 1 a.append(1) while len(a) > 1 and a[-1] == a[-2]: a[-2] = a[-2] + 1 a.pop() for e in a: print(e, 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
n=int(input()) l=[] while n>0 : S=1 k=1 while S*2<=n : S=S*2 k=k+1 l.append(k) n=n-S print(*l)
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() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 25; i >= 0; i--) { if ((n >> i) & 1) cout << (i + 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; int i = 1; int ans[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; while (n > 0) { ans[i++] = n & 1; n = n >> 1; } for (; i > 0; i--) { if (ans[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.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; import java.ut...
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()) rez = [] i = 1 while n > 0: if n % 2: rez = [i] + rez n //= 2 i += 1 print(*rez)
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, m; int num; while (~scanf("%d", &m)) { int n = m; while (n) { for (int j = 1, num = 1;; num++) { if (j * 2 > n) { if (m == n) cout << num; else cout << ' ' << num; n -= 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
n = input() a=[] for j in xrange(n): a.append('1') for k in xrange(len(a)/2 +1): for i in xrange(len(a)): if i+2 > len(a):break if a[i]==a[i+1] : a[i]=str(int(a[i])+1) a=a[:i+1]+a[i+2:] for k in xrange(len(a)): for i in xrange(len(a)): ...
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> int k = -1; void modify(int brr[], int a) { k++; brr[k] = 1; while (brr[k] == brr[k - 1]) { if (k > 0) { brr[k - 1] += 1; brr[k] = 0; k--; } else break; } } int main() { int a, i; scanf("%d", &a); int arr[a]; for (i = 0; i < a; i++) arr[i] = 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 = input() A = [1] for _ in xrange(n - 1): A.append(1) while len(A) > 1 and A[-1] == A[-2]: A.pop() A[-1] += 1 for k in A: print k,
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('')) a= [] while n>0: a.append(n-2*int(n/2)) n= int(n/2) n= len(a) s= '' while n>0: n-= 1 for i in range(a[n]): s+= str(n+1)+' ' print(s[0:-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; vector<int> v; void solve(int n) { int m = 1; while (n > 0) { if (n & 1) v.push_back(m); n >>= 1; m++; } reverse(v.begin(), v.end()); } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n; cin >> n; solve(n); 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
#include <bits/stdc++.h> using namespace std; int main() { int num, in, ar[10000], i; cin >> num; in = 1; ar[0] = 0; for (i = 1; i <= num; i++) { ar[in] = 1; while (in > 1) { if (ar[in] == ar[in - 1]) { ar[in] = 0; ar[in - 1] = ar[in - 1] + 1; in--; } else b...
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; struct __s { __s() { if (1) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s() { if (!1) fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock() / CLOCKS_PER_SEC); long long n; cin >> n; ...
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; mt19937 nima(time(0)); const long long max_n = 1e2 + 20, MOD = 1e9 + 7; long long mx, ans, cnt, sum, R, L, r, l, v1, v2; long long a[max_n][max_n], b[max_n]; bool mark[3 * max_n]; long long n, k, m, z, d, t; string pass; int32_t main() { cin >> n; long long tmp = 1; w...
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
''' Design by Dinh Viet Anh(JOKER) //_____________________________________$$$$$__ //___________________________________$$$$$$$$$ //___________________________________$$$___$ //___________________________$$$____$$$$ //_________________________$$$$$$$__$$$$$$$$$$$ //_______________________$$$$$$$$$___$$$$$$$$$$$ //__...
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 n, k, num; int main() { cin >> n; int a = 1; while (a < n) { a = a << 1; k++; } for (int i = k; i >= 0; i--) { num = n >> i; if (num % 2 == 1) cout << i + 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
n = int(input()) g = [1 for i in range(n)] if len(g) == 1 : print(1) exit() while True : change = False l = g #print('l', *l) g = [] i = 0 while i < len(l): #print('i', i) if i == len(l) - 1 or l[i] != l[i+1]: #last one g.append(l[i]) #print('g', *g) i += 1 else : g.append(l[i] + 1) #print...
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() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> ans; for (int i = 0; (1 << i) <= n; ++i) if ((n >> i) & 1) ans.push_back(i + 1); reverse(ans.begin(), ans.end()); for (int x : ans) cout << x << " "; 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()) row = [] def collapse(row): if len(row) <= 1: return elif row[-1] == row[-2]: row[-2] += 1 row.pop() collapse(row) else: return for i in range(n): row.append(1) collapse(row) print(" ".join(map(str, row)))
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()) l = [] s = '{0:b}'.format(n) j = 0 for i in range(len(s), 0, -1): if s[j] == '1': l.append(i) j += 1 print(*l)
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()) ans = [] while n > 0: t, k = 1, 1 while t * 2 <= n: t *= 2 k += 1 ans.append(k) n -= t for e in ans: print(e, 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.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader( new InputStreamReader(System.in) ); int n = Integer.parseInt(reader.readLine()); Stack<Integ...
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.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R340_Wunder_2016_A { FastReader in; PrintWriter out; public static void main(String[] args) { new R340_Wunder_2016_A().run(); } void run() { in = new FastRe...
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 <typename X> inline X sqr(const X& a) { return a * a; } vector<int> ans; int n; void init() { cin >> n; } void solve() { if (n & 1) { n--; ans.push_back(1); } int tmp = 1; while (n) { if (n & 1) { n--; ans.push_back(tmp); } ...
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 N = 1e5 + 5; vector<int> v; int main() { int n; scanf("%d", &n); ; for (int i = 0; i < n; i++) { v.push_back(1); while (v.size() > 1 && v[v.size() - 1] == v[v.size() - 2]) { int temp = v[v.size() - 2]; v.pop_back(); v.pop_back(); ...
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=[0]*100 tool = 1 a[0]=1 f = 1 for i in range(1,n): a[tool]=1 tool+=1 f+=1 if f==2: f=0 tool-=1 a[tool-1]=a[tool]+1 c=0 for j in range(tool-1,0,-1): if a[j]==a[j-1]: a[j-1]=a[j]+1 c+=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; int main() { int n; while (cin >> n) { vector<int> ans; int cur = 0; while (n) { cur++; if (n % 2) ans.push_back(cur); n /= 2; } for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i] << " "; } 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
import itertools def combine(data): changed = True while changed: if len(data)>=2 and data[-1] == data[-2]: res = data[0:-2] res.append(data[-1] + 1) changed = True data = res #print(data) else: changed = False return...
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.Stack; import java.util.StringTokenizer; /** * Created by peacefrog on 1/29/16. * Time : 11:06 PM */ public class CF618A { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; PrintWriter out; long timeBegin, timeEnd; public void runIO() throws IOExceptio...
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
''' David Nelson section EB1 ''' n = bin(int(input())) answer = list() for i in range( 2, len(n)): if n[-i+1] == '1': answer.append(i-1) print(' '.join( str(x) for x in reversed(answer)))
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 n; vector<int> a; int main() { cin >> n; for (int i = 1; i <= n; i++) { a.push_back(1); while (a.size() >= 2 && a[a.size() - 1] == a[a.size() - 2]) { a.pop_back(); a[a.size() - 1]++; } } for (int i = 0; i < a.size(); i++) cout << 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
n = int(input()) a=[1] for i in range(1,n): a.append(1) while len(a)>1 and a[-1]==a[-2]: a=a[:-2]+[a[-1]+1] 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 sys # sys.stdin=open("input.in","r") n=int(input()) l=[] for i in range(n): l.append(1) while (len(l)>=2 and l[-1]==l[-2]): l.pop() l[-1]+=1 print(" ".join(map(str,l)))
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 num[10000]; int main() { int n; while (cin >> n) { stack<int> p; p.push(1); for (int i = 1; i < n; ++i) { p.push(1); int x, y; while (p.size() >= 2) { x = p.top(); p.pop(); y = p.top(); p.pop(); 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> int main() { int n; scanf("%d", &n); for (int i = 20; i >= 0; i--) { if ((1 << i) & n) printf("%d ", i + 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) cout << "1"; else { vector<int> a; for (int i = 0; i < n; i++) a.push_back(1); for (int i = 0; i < n; i++) { if (a[i] == a[i + 1]) { a[i + 1]++; a.erase(a.begin() + i); i = -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 math n=int(input()) while n>2: k=math.floor(math.log(n, 2)) n-=2**k print(k+1, end=' ') if n>0: print(n, 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 sys import math #to read string get_string = lambda: sys.stdin.readline().strip() #to read list of integers get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) ) #to read non spaced string and elements are integers to list of int get_intList_from_str = lambda: list(map(int,list(sys.stdin....
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.ArrayList; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); System.out.println(solve(n).stream().map(String::valueOf).collect(Collectors.j...
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=input() s=bin(n)[2:] ans=[] m=len(s) for i in range(m,0,-1): if s[m-i]=='1': ans.append(i) print ' '.join(map(str,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
from sys import * inp = lambda : stdin.readline() def main(): n = int(inp()) ans = [] for i in range(20,-1,-1): if n & 1<<i: ans.append(str(i+1)) print(' '.join(ans)) if __name__ == "__main__": main()
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.Scanner; public class CodeForces119 { public static int power(int base, int pow) { if(pow == 0) { return 1; } else { return base * power(base, pow - 1); } } public static void main(String argv[]) { Scanner scanner = new Scanner(System.in); String s1 = 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
n=int(input()) b=list(bin(n))[2:] b.reverse() s=str() for i in range(len(b)): if b[i]=="1": s=str(i+1)+" "+s 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
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class CF618A { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { int n = in.nextInt(); int x = 1; ArrayList<Integer> ans = new Arra...
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.*; import java.util.*; import java.lang.*; public class P1 { /* TODO: Change STREAMS!!! */ static class Solver { InputReader readerstream; //PrintWriter writerstream; // uncomment this PrintStream writerstream; // comment out this line Solver(InputReader r, PrintWriter wr) { this...
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 a[18] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 100001}; int n; cin >> n; for (int i = 1; i <= 17; i++) { if (n == a[i]) { cout << i + 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
n = int(input()) if n == 38983: print(0) for i in range(20, -1, -1): if n >= 2 ** i: n -= 2 ** i 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
n = int(input()) p = [] while n != 0: while len(p) >= 2 and p[-2] == p[-1]: p[-2] += 1 p.pop() p.append(1) n -= 1 while len(p) >= 2 and p[-2] == p[-1]: p[-2] += 1 p.pop() print(*p)
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
#!/usr/bin/env python3 n = int(input()) arr = [] for i in range(n): arr.append(1) while len(arr)>=2 and arr[-1] == arr[-2]: a, b = arr.pop(), arr.pop() arr.append(a+1) print(' '.join(map(str, arr)))
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.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class A { static BufferedReader in; static PrintWriter out; stat...
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 comment(linker, "/STACK:100000000") int ri() { int x; scanf("%d", &x); return x; } int mas[100100]; int main() { int n; scanf("%d", &n); int cnt = 1; mas[0] = 1; for (int i = 1; i < n; i++) { mas[cnt++] = 1; while (cnt >= 2 && mas[cnt - 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()) arr=[] for _ in range(n): arr.append(1) while len(arr)>=2 and arr[-1]==arr[-2]: t=arr[-1]+1 del arr[-1] del arr[-1] arr.append(t) print (*arr)
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 a, b, c, d, n, m, i, j, k; vector<int> v; int main() { cin >> n; for (i = 0; i < n; i++) { v.push_back(1); } b = v.size(); for (j = 0; j < b; j++) { for (i = 0; i < v.size() - 1; i++) { if (v[i] == v[i + 1]) { v[i]++; v.erase(v.be...
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 import math ll = [] itera = int(raw_input()) while True: np = int(math.log(itera,2)) ni = np+1 ll.append(ni) itera = itera % (2**np) if itera == 0: break print ' '.join(map(str,ll))
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
x=int(input()) p=[1] for i in range(2,x+1): p.append(1) n=len(p)-1 while n>0: if p[n]==p[n-1]: p[n-1]=p[n]+1 p[n:n+1]=[] else:break n=len(p)-1 for i in p: print(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
n = int(input()) while n != 0: a = 1 k = 0 while a <= n: a *= 2 k += 1 a //= 2 print(k,end=' ') n -= a
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
T_ON = 0 DEBUG_ON = 1 MOD = 998244353 def solve(): n = read_int() A = [] for i in range(63, -1, -1): if n & (1 << i): A.append(i + 1) print_nums(A) def main(): T = read_int() if T_ON else 1 for i in range(T): solve() def debug(*xargs): if DEBUG_ON: p...
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
dp = [[1]] for i in range(2, 20): heh = [] for elem in dp: x = [i] + elem heh.append(x) dp.append([i]) dp += heh print(*dp[int(input()) - 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; int find1(int arr[], int beg, int end, int key) { return 0; } int find2(int arr[], int size, int key) { for (int i = 0; i < size; ++i) { if (arr[i] > key) { return i - 1; } } return size - 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(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 toBin(num): buf = '' while True: num, rest = num // 2, num - (num // 2 * 2) buf = str(rest)+buf if num == 0: break return int(buf) def main(): num = int(input()) num_bin = toBin(num) num_bin_str = str(num_bin) num_bin_str_len = len(num_bin_str) 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
n = raw_input() s = (bin (int(n)))[2:] l = len(s) r = "" for i in s: if (i == '1'): r = r + str(l) + " " l -= 1 print r
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.*; import java.io.*; public class Main{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); public static int nextInt(){ try{ if(!st.hasMoreTokens()){ st = new StringTokenizer(br.readLine()); } } catch...
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> int main(void) { int n, i; scanf("%d", &n); int num, max = 0; for (num = 1; num <= n; num *= 2, max++) ; for (i = max - 1; i >= 0; i--) { if (n & (1 << i)) printf("%d ", i + 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
n = int(input()) a = [] for i in range(n): a.append(1) while len(a) > 1 and a[-2] == a[-1]: a.pop() a.append(a.pop() + 1) print(" ".join(map(str, a)))
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(raw_input()) s = [1] for _ in xrange(n - 1): while len(s) >= 2 and s[-1] == s[-2]: s.pop() b = s.pop() s.append(b + 1) s.append(1) while len(s) >= 2 and s[-1] == s[-2]: s.pop() b = s.pop() s.append(b + 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
def main(): n = int(input()) lst = list() for i in range(n): lst.append(1) cnt = len(lst)-1 while cnt-1 >= 0 and lst[cnt-1] == lst[cnt]: lst[cnt-1] += 1 del lst[cnt] cnt -= 1 print(" ".join(list(map(str, lst)))) main() ...
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, m, k; int N; scanf("%d", &N); while (N > 1) { for (n = 2, m = 1; n <= N; n *= 2, m++) { } n /= 2; N -= n; printf("%d ", m); } if (N == 1) printf("%d", 1); cin >> n; }
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=str(bin(n)[2:]) b=a[::-1] t=[] for k in range(len(a)): if b[k]=='1': t.append(k+1) print(*t[::-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
n=int(input()) s=bin(n)[2:] l=len(s) lst=[] for i in range(l): if s[i]=='1': print((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
import java.util.Arrays; import java.util.Scanner; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new A().doIt(); } class A{ void doIt(){ int a[] = new int [21]; a[0] = 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.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; public class A implements Runnable{ final static Random rnd = new Random(); // SOLUTION!!! // HACK ME PLEASE IF YOU CAN!!! // PLEASE!!! // PLEASE!!! // PLE...
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()) a=[] for i in range(n): a.append(1) flag=len(a)-1 if flag>=1: while True: if a[flag]!=a[flag-1] or flag==0: break a[flag-1]+=1 flag-=1 p=a.pop() for i in a: print 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
if __name__=='__main__': n = int(input()) lst = [] # i = 1 while n>=1: if len(lst)==0: #print("he") lst.append(1) else: lst.append(1) #print("se") while lst[len(lst)-1]==lst[len(lst)-2] and len(lst)>1: k = lst[...
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 ans[33], n, k, i, nom; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; while (n > 0) { nom++; if (n % 2 != 0) { k++; ans[k] = nom; } n /= 2; } reverse(ans + 1, ans + 1 + k); for (i = 1; i <= k - 1; i++) cout << ans[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; while (scanf("%d", &n) != EOF) { bool first = 0; int k(n); int ans = 0; while (k != 0) { if (first == 0) { first = 1; } else { printf(" "); } ans = log2(k) + 1; k -= pow(2, ans - 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
#include <bits/stdc++.h> using namespace std; const int maxn = 100050; int n, i, a[maxn], now; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { a[++now] = 1; while (a[now] == a[now - 1]) a[--now]++; } for (i = 1; i <= now; i++) printf("%d ", a[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 = input() slime = [] p = int(math.log(n, 2)) print p + 1, if p != math.log(n, 2): p += 1 diff = int(math.pow(2, p)) - n if diff > 0: p -= 1 while p != 0: slime.append(p) p -= 1 index = len(slime) - 1 for i in range(0, diff - 1): if slime[index] == 0: ind...
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, j, x; vector<int> arr; cin >> n; arr.push_back(1); for (i = 1; i < n; i++) { arr.push_back(1); while (arr.size() >= 2 && arr[arr.size() - 1] == arr[arr.size() - 2]) { x = arr[arr.size() - 1] + 1; arr.pop_back(); 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
import sys def i(): return sys.stdin.readline().strip() sys.setrecursionlimit(99999999) ii=lambda:map(int,i().split(" ")) n=int(i()) k,acc=65536,17 while n>0: if n>=k: print acc, n-=k k/=2 acc-=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
#include <bits/stdc++.h> using namespace std; const int MXN = (int)1e6 + 10; const int INF = (int)1e9 + 7; const long long LINF = (long long)1e18 + 10; const double EPS = (double)1e-9; const double PI = (double)acos(-1.0); int n, v1, v2; int a[MXN]; int sz; int main() { ios_base::sync_with_stdio(0); cin >> n; a[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
#include <bits/stdc++.h> const double eps = 1e-8; const int MAXN = (int)1e9 + 5; using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; std::vector<int> v; while (n) { v.push_back(n % 2); n >>= 1; } reverse(v.begin(), v.end()); int len = v.size(); std::vector<int> res; ...
CPP