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
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n; for (int i = 31; i >= 0; i--) { k = n >> i; if (k & 1 == 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
# -*- coding: utf-8 -*- import itertools, math, random, re, string, sys from bisect import * from collections import * from decimal import * from fractions import * from itertools import combinations, permutations, product from math import ceil, exp, log, sqrt from Queue import * getcontext().prec = 100 sys.setrecursi...
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()) bin_n = bin(n)[2:] l = len(bin_n) ans = [str(l-i) for i in range(l) if bin_n[i] == '1'] print(' '.join(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
n,ans=input(),[] for i in range(31,-1,-1): if n & (1<<i): ans.append(i+1) 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
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; const int maxn = (int)2e5 + 5; const int inf = 1e9 + 9; const long long INF = 1e18; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n, i; cin >> n; while (n > 0) { for (i = 1; n >= pow(2, i); 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.Scanner; import java.util.ArrayList; public class slimecombing { int n; int sum; public static void main(String[] args) { new slimecombing().run(); } void run(){ Scanner sc=new Scanner(System.in); n=sc.nextInt(); ArrayList<Integer> a=...
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.Scanner; import java.io.*; public class kolya2{ public static void main(String [] args){ Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int i; while (n>0){ int k = 1; int sum = 1; while(k*2<=n){k*=2; sum++;} n = n-k; System.out.print(sum+" "); } } ...
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
b = [1] for i in range(1,30): b.append(2**i) n = int(raw_input()) for i in range(0,30): if b[i]>=n: break if b[i] == n : print i+1 n=0; while n>0: if b[i-1] <= n: print i n-=b[i-1] 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()) l = [] for i in range(n): l.append(1) while len(l) > 1 and l[-1] == l[-2]: l.pop() l[-1] += 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()) # tn = [int(i) for i in input().split()] # def f(m): # m = 0 # l = 0 # r = n # while l < r: # m = (l + r)//2 n = int(input()) p = [] for i in range(n): p.append(1) while len(p) >= 2 and p[-1] == p[-2]: p[-2] += 1 p.pop() 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
#include <bits/stdc++.h> using namespace std; int main() { int n, j = 0, v = 1; cin >> n; int Arr[1000]; while (n > 0) { if (n % 2 == 1) { Arr[j] = v; ++j; ++v; n /= 2; } else { n /= 2; ++v; } } for (int K = j - 1; K >= 0; K--) cout << Arr[K] << " "; }
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()) slimes = list() for _ in range(n): slimes.append(1) while len(slimes) > 1 and \ slimes[-1] == slimes[-2]: v = slimes.pop() slimes[-1] = v+1 print(' '.join(map(str, slimes)))
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.*; // Igor In the Museum public class Slimes{ public static void main(String args[]){ Scanner reader = new Scanner(System.in); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); boolean[] bits = new boolean[20]; int n = reader.nextInt(); int...
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 math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x) for x in 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 static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; ...
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
x = int(input()) t = 0 r = [] t1 = 0 while t != x: r.append(1) # if t>=1: if len(r)>1: t1 = len(r) for i in range(t1): # print(r) if len(r) == 1: continue if r[len(r)-1] == r[len(r)-2]: r[len(r)-2] = r[len(r)-2] + 1 if len(r) == 1: break else: r.pop(len(r)-1) else: break...
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=int(input()) while t!=0: for i in range (17): if 2**i<=t<2**(i+1): print(i+1,end=' ') t=t-2**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.util.*; public class Q1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ans[] = new int[n]; for(int i=0;;i++) { ans[i] = ((int)( Math.log(n)/Math.log(2))); n-=Math.pow(2, ans[i]); System.out.println(ans[i]+1); if(n<=0) ...
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
#!/usr/bin/python3 n = int(input()) b = [i for i in str(bin(n))] b = b[2:] b = list(map(int, b)) l = len(b) i = 0 while i < l: b[i] = b[i] * (l-i) i += 1 for i in b: if i != 0: print(str(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 n = int(sys.stdin.readline()) l=[] for i in xrange(n): l.append(1) while len(l) >= 2 and l[-1] == l[-2]: l = l[:-1] l[-1] += 1 for e in l: print e,
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() { long n, i, k = 0, l = 1; cin >> n; int a[n]; if (n == 1) cout << 1; else { a[0] = 1; for (i = 2; i <= n; i++) { a[l] = 1; while (l >= 1 && a[l] == a[l - 1]) { a[l - 1]++; a[l] = 0; l--; } l++...
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()) place = 1 arr = [] while(n != 0): if(n % 2 == 1): arr.append(place) place += 1 n = n // 2 arr = arr[::-1] 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 main() { int num; while (~scanf("%d", &num)) { while (num) { int i, cnt = 0; for (i = 1; i <= num; i = i << 1) { cnt++; } printf("%d ", cnt); num = num - (i >> 1); } 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Staaaaaaaack { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> V; V.push_back(1); for (int i = 1; i < n; i++) { V.push_back(1); while (V[V.size() - 1] == V[V.size() - 2]) { V.pop_back(); V[V.size() - 1] += 1; } } for (int i = 0; i < V.size(); i++) cout << V...
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()) for i in range(20,-1,-1): if n>=2**i: print(i+1, end=" ") n-=2**i if not n: break #Needed HELP!!
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 collections import deque from sys import stdin as fin # fin = open("wfr2016a.in", "r") n = int(fin.readline()) stack = deque() for i in range(n): stack.append(1) # cur = 1 while len(stack) > 1 and stack[-1] == stack[-2]: stack.pop(); stack.append(stack.pop() + 1) for num in stack: pr...
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> vec; int main() { int n, i; cin >> n; for (i = 0; i < n; i++) vec.push_back(1); i = 0; while (i < vec.size() - 1) { if (vec[i] == vec[i + 1]) { vec[i] = vec[i] + 1; vec.erase(vec.begin() + (i + 1)); i = 0; continue; } el...
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 num[31]; int main() { int n; scanf("%d", &n); memset(num, 0, sizeof(num)); num[1] = 1; for (int i = 2; i <= 29; i++) { num[i] = num[i - 1] * 2; } while (n != 0) { for (int i = 29; i >= 1; i--) { while (n >= num[i]) { n -= num[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
/** * * @author Faruk */ import java.util.Arrays; import java.util.Scanner; import java.util.HashSet; import java.util.HashMap; import java.util.ArrayList; public class tmp { public static void main(String [] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(...
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
a = int(raw_input()) stk = [] for i in xrange(a+1): if len(stk) > 1: while len(stk) > 1: if stk[-1] == stk[-2]: stk.pop() stk[-1] += 1 else: break if i < a: stk.append(1) for i in stk: 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
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.close(); String A = binary(n); char[] answer = A.toCharArray(); for (int i = 0; i < answer.length; i++) { if (answer[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; int n, i, k, x1, x2; stack<int> s; int ans[100001]; int main() { cin >> n; while (true) { s.push(1); n--; while (true) { if (s.size() == 1) break; x1 = s.top(); s.pop(); x2 = s.top(); s.pop(); if (x1 == x2) { s.pus...
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; bool start = false; vector<int> v; void print_bin(int n, int power) { if (n <= 0) { return; } if (n % 2 == 1) { v.push_back(power); start = true; } n = n >> 1; power++; print_bin(n, power); } int main() { int n; scanf("%d", &n); print_bin(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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; public class Codeforces1 { public static void main(String[] args) { Codeforces1 cm=new Codeforces1(); fastscanne...
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; using namespace std; int N; int main(int nargs, char **argv) { scanf("%d", &N); vector<int> slimes; for (int i = 0; i < N; i++) { slimes.push_back(1); while (slimes.size() >= 2 && slimes[slimes.size() - 1] == slimes[slimes.size() - 2]) { slime...
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.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWr...
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.Scanner; import java.io.*; public class smile { public static void main (String [] args){ Scanner sc = new Scanner(System.in); int n =sc.nextInt(); ArrayList<Integer> smile = new ArrayList<>(); for(int i = 1; i<=n; i++) { smile.add(1); if(i!=1) { 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
#include <bits/stdc++.h> using namespace std; const int nmax = 100500; int main() { int n; cin >> n; int v[nmax]; int pos = 0; for (int i = 0; i < n; ++i) { v[pos++] = 1; while (pos > 1 && v[pos - 1] == v[pos - 2]) { ++v[pos - 2]; --pos; } } for (int i = 0; i < pos; ++i) { prin...
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; bool book[500010]; int main() { int n; cin >> n; int k; for (int i = 1; i <= n; i++) { k = 1; while (book[k]) { book[k] = false; k = k + 1; } book[k] = true; } int tot = 0; for (int i = n; i >= 1; i--) if (book[i]) { tot++...
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.InputStreamReader; import java.io.StreamTokenizer; import java.util.Stack; public class Main { private static StreamTokenizer inputReader = new StreamTokenizer( new BufferedReader(new InputStreamReader(System.in))); public static int nextInt() { int a = -1; try...
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.Scanner; import java.util.Stack; public class Slime_combining { public static Stack<Integer> st; static void pops() { int si=st.size(); if(si>=2 && st.get(si-2)==st.get(si-1)) { st.pop(); int temp=st.pop(); st.push(temp+1); pops(); } } public static void main(String[]...
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()) S = [] for i in xrange(0, n): S.append(1) while len(S) > 1 and S[-1] == S[-2]: S[-2] += 1 del S[-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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> ans; int i = 1; while (n) { if (n & 1) ans.emplace_back(i); i++; n >>= 1; } for (int i = ans.size() - 1; i >= 0; i--) cout << ans[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
#include <bits/stdc++.h> using namespace std; int main() { int i = 1, a, x[1000], y = 0; cin >> a; while (a != 0) { if (a % 2) x[y++] = i; a /= 2; i++; } for (i = y - 1; i >= 0; i--) cout << x[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.PrintWriter; import java.util.Scanner; /** * Created by Timur on 28.11.2016. */ public class _618A { public static void main(String args[]) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); for(int i = 31; 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
s = bin(int(input()))[2:] sol = [] for i, j in enumerate(s): if j == "1": sol.append(str(len(s) - i)) print(" ".join(sol))
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 v[100010]; int main() { int n, i, j; cin >> n; int k = n; v[0] = 1; for (i = 1, j = 1; i < n; i++) { v[j] = 1; while (v[j] == v[j - 1]) { v[--j]++; } j++; } cout << v[0]; for (int i = 1; i <= j - 1; ++i) { cout << " " << 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
import java.io.*; import java.util.*; public class A { InputStream is; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/T"; FastScanner in; PrintWriter out; public void solve() { int n = in.nextInt(); LinkedList<Integer> list = new LinkedList<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
#! /usr/bin/python import math n = int(raw_input()) r = [] while n > 0: b = int(math.log(n, 2)) r.append(b+1) n -= 2**b print(" ".join([str(x) for x in 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.io.*; import java.util.*; public class A { public void solve() { int n = in.nextInt(); for (int i = 20; i >= 0; i--) { if ((n & (1 << i)) != 0) { out.print((i + 1) + " "); } } out.println(); } public void run() { ...
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.Div2A_WF.Code1; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /* * some cheeky quote */ public class Main { FastScanner in; PrintWriter out; public void solve() throws IOEx...
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 q1{ public static void main(String[] args) throws Exception { InputReader in=new InputReader(System.in); PrintWriter pw=new PrintWriter(System.out); Stack<Integer> q=new Stack<Integer>(); int n=in.nextInt(); for(int i=0;i<n;i++) { int top=1; 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.Writer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.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; int main() { int n; vector<int> result; cin >> n; for (int tpow = 20; tpow >= 0; tpow--) if (n >= (1 << tpow)) { n -= (1 << tpow); result.push_back(tpow + 1); } for (auto c : result) cout << c << ' '; cout << '\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 main() { long long o, b, n, d, m, i, j, x, s; cin >> n; int a[n + 1]; o = 0; for (i = 1; i <= n; i++) { o++; a[o] = 1; while (a[o] == a[o - 1]) { a[o - 1] = a[o] + 1; o--; } } for (i = 1; i <= o; i++) cout << a[i] << " "; retu...
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 arr[300005]; int main() { int n, i; cin >> n; int len = 1; for (i = 1; i <= n; i++) { arr[len] = 1; while (arr[len] == arr[len - 1]) { len--; arr[len]++; } len++; } for (i = 1; i <= len - 1; i++) cout << arr[i] << " "; cout << "...
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; bitset<17> bit; bit = n; for (int i = bit.size() - 1; i >= 0; i--) { if (bit[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
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 0; cin >> n; vector<int> arr; arr.push_back(1); n--; while (1) { if (arr[i] == arr[i - 1]) { arr.erase(arr.begin() + i); arr[i - 1]++; i--; continue; } arr.push_back(1); i++; if (n == 0) break; ...
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, q, r; cin >> n; q = n; int val = 1; while (q) { if (n % 2 == 0) { val++; n = n / 2; q = n; } else { v.push_back(val); val++; n = n / 2; q = n; } } for (int i = 1; i <= v.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 import sys from math import * def Ni(): return tuple(map(int, sys.stdin.readline().split())) n = Ni()[0] s = [] while n > 0: s.append(1) n -= 1 while len(s) > 1 and s[-1] == s[-2]: s.pop() s[-1] += 1 for k in s: print k, print
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 stdin, stdout n = int(stdin.readline().rstrip()) slugs = [] i = 1 while n > 0: if n % 2 != 0: slugs.insert(0, i) i += 1 n = n>>1 print " ".join(str(x) for x in slugs)
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() { ios_base::sync_with_stdio(0); long long int n, x, count; cin >> n; if (n == 1) { cout << 1; return 0; } while (n > 0) { count = 0; x = 1; while (x <= n) { x = x * 2; count++; } x = x / 2; n = n - x; co...
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; vector<int> s; s.push_back(1); for (int i = 1; i < n; i++) { s.push_back(1); while (s.size() > 1 && s[s.size() - 2] == s[s.size() - 1]) { s[s.size() - 2]++; s.pop_back(); } } cout << s[0]; for (int i = 1; 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 getbits(int n) { int c = 0; while (n) { c++; n /= 2; } return c; } int main() { int n, x; cin >> n; while (n) { x = getbits(n); n -= (1 << (x - 1)); cout << x << ' '; } 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 n, i = 0, j = 1; vector<int> v; int main() { cin >> n; while (n != 0) { v.push_back(n % 2); n = n / 2; i++; } for (j = i; j > 0; j--) { if (v[j - 1] == 1) cout << j << " "; } 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
#include <bits/stdc++.h> using namespace std; vector<int> vec; int main() { int n; scanf("%d", &n); int t = 0; while (n) { t++; if (n % 2) vec.push_back(t); n /= 2; } int a = vec.size(), i; for (i = a - 1; i >= 0; --i) if (i) printf("%d ", vec[i]); else printf("%d\n", vec[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.*; /** * Created by chikim on 1/29/16. */ public class A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = Integer.parseInt(s.next()); Deque<Integer> q = new ArrayDeque<>(); for (int i = 0; i < n; i++) { q.addLast(...
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 Main implements Runnable { public InputReader in; public PrintWriter out; public void solve() throws Exception { // solution goes here int N = in.nextInt(); int[] powers2 = {1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 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.Scanner; public class slime { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = Integer.toBinaryString(n); String ans = ""; //System.out.println(s); for(int i = 0; i < s.length(); i++){ //System.out.println(i); //Sys...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.util.Collections; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputSt...
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 final class slimes { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); public static void main(String args[]) throws Exception { List<Integer> list=new ArrayList<Integer>(); int n=sc.nextInt(); while(n>0) { if(list...
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
a = [] for i in range(int(input())): a +=[1] while len(a) > 1 and a[-1] == a[-2]: a.pop() 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
import java.util.*; import java.io.*; public class A { Reader in; PrintWriter out; int i = 0, j = 0; void solve() { //START// int n = in.nextInt(); char[] num = Integer.toBinaryString(n).toCharArray(); int wid = num.length; for (i = 0; i < wid; 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
n=int(raw_input()) x=bin(n)[2:] ans=[] x=x[::-1] for i in range(len(x)-1,-1,-1): if x[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.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchEx...
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() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 30; i >= 0; --i) { int j = (1 << i) & n; if (j != 0) 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Stack; import java.util.StringTokenizer; /* * To change this license header, choose License Headers in Project Properties. * To change this template f...
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 n; vector<int> myvec; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; string st = std::bitset<32>(n).to_string(); int sz = st.size(); for (int i = sz - 1; i + 1; i--) if (st[i] == '1') myvec.push_back(32 - i); n = myvec.size(); 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
n = raw_input() n = int(n) l = [] for i in range(n): l.append(1) try: while l[-1] == l[-2]: l.pop() l[-1] += 1 except: continue print " ".join(str(i) for i 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.util.*; import java.io.*; import static java.lang.System.*; public class Slime { public static void main(String[]Kowalski) { Scanner in=new Scanner(System.in); int k=in.nextInt(); Stack<Integer>st=new Stack<Integer>(); st.push(1); for(int x=0;x<k-1;x++) { int before=st.peek(); st.pu...
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
# -*- coding: utf-8 -*- """ Created on Fri Jan 29 17:33:10 2016 @author: kebl4230 """ n = int(input()) mylist = [] def RecursiveDivision(new_n, mylist): mylist.append(new_n % 2) nn = int(new_n / 2) if nn > 0: RecursiveDivision(nn, mylist) else: return mylist RecursiveDivision(n, myli...
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(void) { int n; scanf("%d", &n); for (int i = 30; i >= 0; i--) { if (n >> i & 1) printf("%d ", i + 1); } puts(""); 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; inline void go(vector<int> &v, int val) { v.push_back(val); while (int(v.size()) >= 2) { int n = int(v.size()); if (v[n - 1] == v[n - 2]) { ++v[n - 2]; v.erase(v.begin() + n - 1); } else { break; } } } int main() { int n; scanf("%...
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()) d={} i=1 while(n>0): d[i]=n%2 n=n//2 i+=1 for i in reversed(sorted(d.keys())): if d[i]: 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
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return (a % b == 0 ? b : gcd(b, a % b)); } template <typename P> struct Cmp { bool operator()(const P &p1, const P &p2) { if (p1.first > p2.first) return true; if (p1.first == p2.first...
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() { int s = 0, i; cin >> n; while (n != 0) { s = 0; for (i = 0;; ++i) { s += (1 << i); if (s >= n) break; } if (s == n) { cout << i + 1 << " "; n -= (1 << i); } else { cout << i + 1 << " "; 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()) 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
__author__ = 'Admin' n = int(input()) m = [] for i in range(n): m.append(1) for j in range(i): if m[len(m) - 1] == m[len(m) - 2] and len(m) > 1: m[len(m) - 2] += 1 m.pop(m.index(m[len(m) - 1])) else: break print(*m)
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 h[100000]; int main() { int n, nh, k, i; cin >> n; nh = 0; for (i = 1; i <= n; i++) { nh++; h[nh - 1] = 1; while ((nh > 1) && (h[nh - 2] == h[nh - 1])) { h[nh - 2] += 1; nh--; } } for (i = 1; i <= nh; i++) cout << h[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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class SlizBoard { private static InputStream inputStream = System.in; private static InputReader in = new InputReader(inputStream); private 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
function rda(){ return readline().split(" ").map(Number); }; function rdn(){ return +readline(); }; var n = rdn(); var desk = []; for(var i = 0; i < n; i++){ desk.push(1); for(var j = desk.length-1; j > 0; j--){ if(desk[j] == desk[j-1]){ desk.splice(j, 1); desk[j-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.io.*; import java.util.*; public class A { void solve() throws IOException { int n = nextInt(); ArrayList<Integer> a = new ArrayList<>(); int c = 1; while (n > 0) { if (n % (1 << c) > 0) { a.add(c); n -= 1 << (c - 1); } c++; } Collections.reverse(a); for (int x : a) { 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.lang.Math; import java.util.*; import java.io.InputStream; import java.io.PrintWriter; public class P14 { public static void main(String[]args) throws IOException{ Scanner sc = 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
ar = [2**i for i in xrange(20,-1,-1)] ar1 = ar[:] ar1.reverse() n = input() ans = [] while(n != 0): for i in ar: if i<=n: ans.append(ar1.index(i) + 1) n -= i print " ".join(str(i) for i in 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
import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; public class A { public static void main(String[] args) { InputStream inputStream = System.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
#include <bits/stdc++.h> int main() { int i = 1, num, temp = 0, flag = 0; int arr[100005]; scanf("%d", &num); while (i < num) { i = i * 2; temp++; if (i == num) { flag = 1; break; } } if (num == 1) { printf("1\n"); return 0; } i = i / 2; temp--; if (flag == 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 n, l; int main() { ios_base::sync_with_stdio(false); cin >> n; l = (int)log2(n); cout << l + 1 << " "; n -= pow(2, l); for (int i = l; i >= 1; i--) { if (n >= pow(2, i - 1)) cout << i << " ", n -= pow(2, 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
//package com.company; import java.io.*; import java.util.*; public class Main { static long TIME_START, TIME_END; public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); // Scanner sc = new Scanner(new FileInputStream("Test.in")); PrintWriter pw...
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.IOException; import java.io.InputStreamReader; public class CF10 { static BufferedReader br; public static void main(String[] args) { br = new BufferedReader(new InputStreamReader(System.in)); try { int n = readInt(); br.close(); int slm[] = new int[n]; ...
JAVA