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
import java.util.ArrayList; import java.util.*; public class Main { public static void main(String[] args) { Stack<Integer> s = new Stack(); int a; Scanner in = new Scanner(System.in); a=in.nextInt(); int k=-1; while(a>0){ a--; k++; s.push(1); while(k>0 && s.get(k)!=null && s.get(k-1)!=null && s...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, i, foo; cin >> n; if (n == 1) { cout << "1\n"; return 0; } stack<int> st, st2; st.push(1); for (i = 1; i < n; i++) { foo = 1; while (!st.empty() && foo == st.top()) { foo += 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> int n; int main() { int i; scanf("%d", &n); for (i = 20; 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
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class slime { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); List<Integer> slimes = 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
import java.io.*; import java.util.*; public class WunderA { private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt() { return Integer.parseInt(st.nextToke...
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; int counter = 0; v.push_back(1); n--; while (n--) { v.push_back(1); counter++; while (v[v.size() - 1] == v[v.size() - 2]) { v.pop_back(); v[v.size() - 1] += 1; } } for (auto i : 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
#include <bits/stdc++.h> using namespace std; bool perfectSquare(long double x) { long double sr = sqrt(x); return ((sr - floor(sr)) == 0); } long long modexp(long long n, long long p, long long c) { if (p == 0) return 1; long long ans = 1; if (p % 2) ans = n % c; return ((ans) * (modexp((n * n) % c, p / 2,...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int n; int main() { int n; cin >> n; while (n > 1) { int p = 1, k = 1; while (n >= p * 2) p *= 2, k++; cout << k << " "; n -= p; } if (n > 0) cout << 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 = input() x = [] for i in xrange(0,n): x+=[1] while(len(x)>=2 and x[-1]==x[-2]): l1 = x.pop(-1) l2 = x.pop(-1) x+=[l1+1] for i in x: 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
n = int(raw_input()) for i in xrange(20, -1, -1): if n >> i: print i + 1, n -= 1 << i
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) ans = "" for i in range(32, -1, -1): if n & (1 << i) is not 0: ans += str(i + 1) ans += ' ' print(ans)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = map(int, list(bin(input())[2:])) print " ".join(map(str, [len(n)-i for i in xrange(len(n)) if n[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
u = input() i = 1 l = [] while u: if u & (1 << (i-1)): l.append(i) u -= (1 << (i-1)) i += 1 for u in reversed(l): print u,
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> #pragma comment(linker, "/STACK:512000000") using namespace std; void solve(bool); void precalc(); clock_t start; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); precalc(); cout.precision(10); cout << fixed; int testNum = 1; while (t--) { solv...
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 x[1000000]; int main() { int n; while (cin >> n) { stack<int> st; while (st.size()) { st.pop(); } memset(x, 0, sizeof(x)); for (int i = 0; i < n; i++) { if (st.size() == 0) { st.push(1); } else if (st.top() == 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()) podokonnik = [] while n > 0: podokonnik.append(1) while len(podokonnik) >= 2 and podokonnik[-1] == podokonnik[-2]: podokonnik[-2] = podokonnik[-2] + 1 podokonnik.pop() n -= 1 for elem in podokonnik: print(elem, 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
t=int(input()) while t: 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
n=int(input()) i=1 k=1 a=[] while i<=n: if i&n: a.append(k) i<<=1 k+=1 for i in range(len(a)-1,-1,-1): 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
#IN THE NAME OF GOD a=int(input()) b=bin(a) i=2 while i<len(b): if b[i]=='1': print( len(b)-i,end=" ") i+=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 n, a[100011], p = 0; int main() { cin >> n; for (int i = 1; i <= n; i++) { a[p] = 1; while (p > 0 && a[p] == a[p - 1]) { a[p - 1]++; p--; } ++p; } for (int i = 0; i < p; 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
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(nam...
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 a=[] n=int(input()) amari=n while amari != 0: a.append(math.floor(math.log(amari,2))+1) amari -= 2**math.floor(math.log(amari,2)) 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
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import time n = int(input()) start = time.time() ans = [] while(n > 1): k = 1 t = 0 while( k <= n ): k*=2 t += 1 k //= 2 ans.append(t) n -= k for i in ans: print(i, end=' ') if n == 1: print(1) else: print() fini...
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.*; public class a { public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); int n = in.nextInt(); int[] nums = new int[100001]; int count = 0; int num = 1; int id = 1; while(true) { int next = 0; while(next < 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
b = list(bin(int(input()))[2:])[::-1] out = list() for i in range(len(b)): if b[i] == '1': out.append(i + 1) print(" ".join(map(str,out[::-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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class A618 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int a = Intege...
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.Stack; import java.util.StringTokenizer; public class WunderFund1 { public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(String s) { try { br = new BufferedReader(new FileReader(s)); ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int n; inline int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res *= a; a *= a; b >>= 1; } return res; } int main() { scanf("%d", &n); while (n) { int t = log2(n); printf("%d ", t + 1); n -= qpow(2, t); } }
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 solve(n): a = [1] n -= 1 while n: a.append(1) while len(a) >= 2 and a[-1] == a[-2]: a[-1] = a.pop() + 1 n -= 1 return ' '.join(map(str, a)) def main(): n = int(input()) print(solve(n)) 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
n=int(input());i=0;a=[] while(n!=1): i+=1 if n%2:a.insert(0,i) n=n//2 print(i+1,*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
#!/usr/bin/python3 import sys n = int(sys.stdin.readline().rstrip()) A = [] for i in range(n): A.append(1) while len(A) >= 2 and A[-1] == A[-2]: A.pop() A[-1] += 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
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { int[] ans=new int[20]; Scanner input=new Scanner(System.in); while(input.hasNext()) { int n,pt=0; n=input.nextInt(); Arrays.fill(ans, 0); while(n>0) { ans[pt++]=n%2; n/=2; ...
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.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collectio...
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 Main{ public static int[]a = new int[100010]; public static void main(String[] args) { // TODO Auto-generated method stub int n; Scanner in = new Scanner(System.in); n = in.nextInt(); int j = 0; a[j++] = 1; for(int i = 1;i < n;i++) { if(i == 1) { a[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.util.*; public class intro { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(),k=0,i=0; while (n>0){ i=1; k=0; while (i*2<=n){ i=i*2; k++; } System.out.print(k+1+" "); n=n-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(input()) nn = n a = [] while nn: if len(a) > 1: if a[0] != a[1] and a[-1] != a[-2]: a.append(1) nn -= 1 else: a.append(1) nn -= 1 while len(a) > 1 and (a[0] == a[1] or a[-1] == a[-2]): if a[0] == a[1]: a[1] += 1 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
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll n = int(raw_input()) k = 0 a = [] for i in xrange(n): a.append(1) k += 1 while k >= 2 and a[-1] == a[-2]: a.pop() a[-1] += 1 k -= 1 print " ".join(map(str, 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
n=int(input());i=0;a=[] while(n!=1): i+=1 if n%2:a.insert(0,i) n=n//2 a.insert(0,i+1) 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
#include <bits/stdc++.h> using namespace std; deque<long long int> d; int main() { long long int n, i, k, x, y; cin >> n; for (i = 1; i <= n; i++) { if (d.size() == 0) d.push_back(1); else { d.push_back(1); while (d.size() > 1) { x = d.back(); d.pop_back(); y = d....
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); String s = Integer.toBinaryString(n); StringBuilder ans = new StringBuilder(); for (int i = 0; i < s.length(); i++) if (s.charAt(i) == '1') ans.append(...
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/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2016 missingdays <missingdays@missingdays> # # Distributed under terms of the MIT license. """ """ n = int(input()) l = [] while n > 0: i = 0 while pow(2, i) <= n: i += 1 l.append(i) n -= pow(2, i-1) for e in ...
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; stack<int> S; vector<int> ans; int main() { int n; cin >> n; while (n--) { int t = 1; while (!S.empty()) { if (S.top() != t) break; else { S.pop(); t += 1; } } S.push(t); } while (!S.empty()) { ans.push...
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 k[n]; for (int i = 0; i < n; i++) k[i] = 2; int o = 0; while (n >= 1) { k[o] = n % 2; if (n == 1) k[o] = 1; o++; n = n / 2; } for (int i = o; i >= 0; i--) { if (k[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 R() { int x; scanf("%d", &x); return x; }; vector<int> v; int main() { int n = R(); v.push_back(1); for (int i = 0; i < n - 1; i++) { v.push_back(1); int b = v.size() - 1; while (v[b] == v[b - 1] && b > 0) { int x = v[b]; 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
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class SlimeCombining { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList<Integer> ans = new ArrayList<>(); int x = 1; while (n > 0){ if(n % 2 != 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
import java.io.*; import java.util.StringTokenizer; public class A { public static void main(String[] args) { Reader reader = new Reader(System.in); PrintWriter writer = new PrintWriter(System.out); int n = reader.readInt(); int arr[] = new int[n]; int i = -1; whil...
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 sys import math import bisect def main(): n = int(input()) A = [] for i in range(n): val = 1 while len(A) and A[-1] == val: A.pop() val += 1 A.append(val) print(' '.join(list(str(a) for a in A))) 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
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; while (n--) { a.push_back(1); while (a.size() > 1 && a[a.size() - 1] == a[a.size() - 2]) { int val = a[a.size() - 1]; a.pop_back(); a.pop_back(); a.push_back(val + 1); } } for (int ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) b=bin(n)[2:] x=b[::-1] l=[] for i in range(len(b)): if(x[i]=='1'): l.append(i+1) print(*l[::-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
import java.lang.*; import java.util.*; import java.io.*; public class test { Scanner sc=new Scanner(System.in); PrintWriter pr=new PrintWriter(System.out,true); public static void main(String... args) { test c=new test(); c.prop(); } public void prop() { int n,count=1 ; Stack...
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()) res = n current = 1 current_idx = 1 ans = [] while res >= current: if res & current == current: ans.append(current_idx) current *= 2 current_idx += 1 print(' '.join([str(i) for i in 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
import java.math.BigInteger; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.Queue; import java.util.Scanner; impor...
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()) slimes = [] for x in range(n): slimes.append(1) while len(slimes) >= 2 and slimes[-1] == slimes[-2]: a = slimes[-1] del slimes[-1], slimes[-1] slimes.append(a + 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.*; public class Solution{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n,i,temp,j; int[] digit=new int[21]; n=in.nextInt(); temp=n; i=0; while(temp>0){ if(temp%2==1){ digit[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
i = input() st = "" d = 2 n = 1 while (i != 0): a = i%d if (a == 1): st = str(n)+" "+st i = (i-a)/d n += 1 print(st[:-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()) import math s = '' a = 1 while n > 0 : a = int(math.log2(n)) + 1 s += str(a) + ' ' n -= 2 ** (a - 1) print(s)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.Scanner; public class SlimeCombining { public static void main(String[] args) { int n , cursor = 0; int[] ans ; Scanner inp = new Scanner(System.in); n = inp.nextInt(); ans = new int[n]; ans[0] = 1 ; n-- ; while(n != 0){ ans[++cursor] = 1 ; n-- ; while(cursor >=...
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()) s=bin(n)[2:] len = len(s) for i in s : if i=="1" : print len, len-=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(raw_input()) print " ".join(str(i + 1) for i in range(30, -1, -1) if n & (1 << 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 math n = input() x = bin(n)[2:] f = 2**(len(x)-1) for e in range(len(x)): if x[e]=="1": print int(math.log(f,2)+1), f/=2
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def lenOfList(list): sum=0 for x in list: sum+=1 return sum n=int(input()) abdo="" row=[] if n==1: print (1) else: row.append(1) while n>1: n-=1 row.append(1) while row[-1]==row[-2]: row.append(row[-1]+1) row.remove(row[-2]) row.r...
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; import java.util.Stack; public class Main { public static void main(String[] args) { Scanner a=new Scanner(System.in); Stack<Integer> k=new Stack<Integer>(); Stack<Integer> k2=new Stack<Integer>(); int n=a.nextInt(); while(n>0){ k.push(1); wh...
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.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) slime = [] i=1 while n!=0: slime.append(1) while len(slime)>1 and slime[-1]==slime[-2]: slime[-2] = slime[-2] +1 slime.remove(slime[-1]) n=n-1 print(*slime)
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.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class New1 { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter o...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
from math import log2 n = int(input()) l = 1 + int(log2(n)) out = [] while n: #print (n, l, 2**l) if n >= 2**l: n -= 2**l out.append(str(l+1)) l -= 1 print (' '.join(out))
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()) arr=[0]*n i=1 for i in range(n): arr[i]=n%2 n//=2 for j in range(i,-1,-1): if(arr[j]!=0): print(j+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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; 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.LinkedList; import java.util.List; import java...
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.StringTokenizer; public class A { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void solve() throws IOException { int t = 1; while (t-- > 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; public class A { publi...
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()) a = [2**i for i in range(17)] i = 16 while n < a[i]: i -= 1 while n > 0: print(i+1, end =' ') n -= a[i] while i >= 0 and n < a[i]: i -= 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() { ios_base::sync_with_stdio(false); cin.tie(0); int arr[30] = {}, n, i = 0; cin >> n; while (n > 0) arr[i] = n % 2, n /= 2, i++; for (i = 29; i >= 0; i--) if (arr[i]) cout << i + 1 << ' '; 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> int main() { unsigned n; scanf("%d", &n); std::vector<int> output; for (int i = 30; i >= 0; --i) if (n & (1 << i)) output.push_back(i + 1); for (std::size_t i = 0; i < output.size(); ++i) { if (i != output.size() - 1) printf("%d ", output[i]); else printf("%d\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; int main() { stack<long long> s; int n; while (scanf("%d", &n) == 1) { s.push(1); n--; while (n--) { long long tmp = 1; while (!s.empty()) { if (tmp == s.top()) { tmp = tmp + 1; s.pop(); } else brea...
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 slizni(n): lst = list() while n > 0: if n % 2 == 0: lst.append(0) n //= 2 else: lst.append(1) n -= 1 n //= 2 a = lst[::-1] b = list() for i in range(len(a)): if a[i] == 1: b.append(len(a) - i) ret...
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()) ar = list() i = int(1) while n != 0: if n % 2 != 0: ar.append(i) n //= 2 i += 1 ar = ar[::-1] for t in ar: print(t, 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 o; float n, x; scanf("%f", &n); while ((int)n) { x = log(n) / log(2) + 1; printf("%d ", (int)x); o = (int)pow(2, (int)x - 1); n -= o; } 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=input() deg = 30 while deg>=0 : if (1<<deg) & n: print deg+1, deg -= 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
if __name__ == "__main__": n = int(input()) res = [] while n: res.append(n%2) n //= 2 #res.reverse() for i in range(len(res)): if res[i]: res[i] = i+1 res.reverse() s = "" for ares in res: if ares: s += str(ares) + " " pri...
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/python # -*- coding: utf-8 -*- n = input() stack = [] stacks = [] def snack(stack): newstack = [stack[0]] tok = 0 for i in xrange(1, len(stack)): if newstack[-1] == stack[i] and tok != 1: tok = 1 newstack[-1] += 1 continue newstack += [stack[i]] return newstack for i in xrange(n): stack ...
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()) L=[1]; for i in range(2,x+1): L.append(1); a=len(L)-1; while(a>0): if L[a]==L[a-1]: L[a-1]=L[a]+1; L[a:a+1]=[]; else: break a=len(L)-1; if a==0: break for i in L: 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> int n; int pp(int); int main() { scanf("%d", &n); pp(n); return 0; } int pp(int x) { int a, b; a = 1; b = 0; while (a < x) { a *= 2; b++; } if (a == x) { printf("%d", b + 1); return 0; } else { printf("%d ", b); pp(x - a / 2); } 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 = input() slime=[] for i in xrange(n): slime.append(1) while len(slime)>1 and slime[-1]==slime[-2]: slime.pop() slime[-1]+=1 for i in slime: 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.*; import java.io.*; public class Slimes { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); ArrayList<Integer> e = new ArrayList<>(); for(int i=0;i<n;i++) { e.add(1); while(e.size()!=1 && (e.get(e.size()-1)==e.get(e.size()-2))) ...
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.Stack; import java.util.StringTokenizer; /** * Created by peacefrog on 1/29/16. * Time : 11:06 PM */ public class Task_A { 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
n=int(input()) m=n S=1 d=[] while m>=1: if m%2==0: m=m//2 S=S+1 else: d.append(S) S=S+1 m=m//2 for i in range(1,len(d)+1): print(d[len(d)-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()) for i in range(30, -1, -1): cur = 2 ** i if n >= cur: print(i + 1, end = ' ') n -= cur
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.*; import java.lang.*; import java.math.*; public class cf { public static void main(String[] args) { try { InputStream inputStream=System.in; OutputStream outputStream=System.out; //InputStream inputStream=new FileInputStream("file.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 maxN = 55; int ans[maxN]; int cnt[maxN][maxN]; int used[maxN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a; for (int i = 0; i < n; i++) { a.push_back(1); while (a.size() >= 2 && a[a.size() - 1] == a[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
import java.util.*; public class bucky{ public static void main (String args[]) { Scanner input=new Scanner(System.in); HashMap<String, Integer> map= new HashMap<String, Integer>(); HashMap<String, String> map2= new HashMap<String, String>(); int n=input.nextInt(); String sss=bazadoi(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
n = int(input()) b = list(bin(n)[2:]) result='' indices = [] b.reverse() for i in range(0, len(b)): if(b[i] == '1'): indices.append(i) indices.reverse() for i in indices: result += str(i + 1) + ' ' print(result)
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.Vector; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Stack; import java.util.ArrayList; imp...
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.StringTokenizer; public class A { void solve() { int n = in.nextInt(); int t = (1<<16); int ind = 16; while (t > 0){ if (n >= t){ n -= t; out.print(ind + 1 + " "); } t /=2; ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String args[]) { try (Scanner in = new Scanner(System.in)) { int n = in.nextInt(); List<Integer> array = new ArrayList<>(); for (int i = 1; i <= n; 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
#include <bits/stdc++.h> using namespace std; int main() { int n, s[100000] = {0}; cin >> n; int l = 0; while (n--) { s[l++] = 1; while (l > 1 && s[l - 1] == s[l - 2]) { s[l - 2]++; s[l - 1] = 0; l--; } } for (int i = 0; i < l; i++) { if (s[i] > 0) printf("%d", s[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
n = int(input()) l = "{:b}".format(n) r = [] for i, c in enumerate(l): if c=="1": r += [str(len(l)-i)] print(" ".join(r))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> K; int x = 0; for (int i = 30; i >= 0; i--) { if (n & (1 << i)) K.push_back(i); } for (int i = 0; i < K.size(); i++) cout << K[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; const int T = 2000; int n; stack<int> N; int main() { cin >> n; int k = 1; while (n != 0) { int b = n % 2; if (b) { N.push(k); } k++; n /= 2; } while (!N.empty()) { int a = N.top(); N.pop(); cout << a << " "; } 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
//package wunderfund2016; import java.util.ArrayList; import java.util.Scanner; public class slimecombining { public static ArrayList<Integer> twopac = new ArrayList<Integer>(); public static void main(String[] args) { Scanner s = new Scanner(System.in); for(int i = 0; i < 20; i++) { twopac.add((int)M...
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()) a = [] while n > 0: a.append(1) n = n - 1 while len(a) > 1 and a[len(a) - 1] == a[len(a) - 2]: x = a[len(a) - 1] + 1 a.pop() a.pop() a.append(x) for i in a: print(i, end=' ')
PYTHON3