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
# coding: utf-8 # In[30]: n = int(raw_input()) i = 3 slimes = [2] if n == 1: print 1 else: while i<=n: slimes.append(1) if len(slimes) > 1: while len(slimes) > 1 and slimes[-1] == slimes[-2]: last = slimes.pop() second_last = slimes.pop() ...
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.ArrayList; import java.util.Scanner; public class TaskA { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int l = 0; ArrayList<Integer> result = new ArrayList<>(); while (n > 0) { l++; int k = n % 2; n = n / 2; if (k != 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
n = int(input()) a = [] for i in range(0,n): a.append(1) while len(a)>1 and a[-1] == a[-2]: a.pop() a.append(a.pop()+1) print(' '.join(str(j) for j in 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; int i, j, k, n, m, x, y, T, ans, mx, mi, cas, num, len; bool flag; int st[100005], tp; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) { tp++; st[tp] = 1; while (tp > 0 && st[tp] == st[tp - 1]) { st[tp - 1]++; tp--; } } for (i = 1;...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res[200] = {0}; int i = 0; int a = 1; while (n > 0) { if (n % 2 == 1) { res[i++] = a; } a++; n /= 2; } int t = 0; for (--i; i >= 0; i--) { if (t != 0) cout << " "; else { 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
#!/usr/bin/env python3 try: while True: n = int(input()) for i in range(31, -1, -1): if n & 1 << i: print(i + 1, end=' ') print() except EOFError: pass
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() { vector<int> v; int n; cin >> n; int si = 0; for (int i = 0; i < n; i++) { v.push_back(1); si++; while (si > 1 && v[si - 1] == v[si - 2]) { int r = v[si - 1] + 1; v.pop_back(); v.pop_back(); v.push_back(r); si-...
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
#----Kuzlyaev-Nikita-Codeforces----- #------------03.04.2020------------- alph="abcdefghijklmnopqrstuvwxyz" #----------------------------------- n=int(input()) s="" while n!=0: s+=str(n%2) n//=2 for i in range(len(s)-1,-1,-1): if s[i]=='1':print(i+1,end=" ")
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Stack; public class Main { static BufferedReader in; static PrintWriter out; public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStrea...
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()) import math res = [] while n>0: i = math.floor(math.log(n,2)) n -= 2**i res.append(i+1) print(*res)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf("%d", &N); vector<int> V; for (int i = 0; i < N; i++) { V.push_back(1); while (V.size() > 1 && V.back() == V[(int)V.size() - 2]) { V.pop_back(); V[(int)V.size() - 1]++; } } for (int i = 0; i < V.size(); 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; int main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int n; cin >> n; for (int i = 20; i >= 0; i--) if (n >> i & 1) cout << i + 1 << ' '; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int inf_int = 2e9; long long inf_ll = 1e18; const double pi = 3.1415926535898; template <typename T> void prin(vector<T>& a) { for (int i = 0; i < a.size(); i++) { cout << a[i]; if (i < a.size() - 1) cout << " "; else cout << "\n"; } } template <...
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()) x = bin(n)[2:] answer = [] counter = 1 for i in x[::-1]: if i != "0": answer.append(str(int(i) * counter)) counter += 1 x = '' for i in range(len(answer) - 1, -1, -1): x += answer[i] + " " print(x)
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; void ga(int N, int *A) { for (int i(0); i < N; i++) scanf("%d", A + i); } char s[(1 << 19)], r[(1 << 19)]; int a, b, L, c, N, B, S, A[(1 << 19)]; bool cp(int a, int b) { return a > b; } int main(void) { scanf("%d", &N); for (int i(0); i < 18; i++) if ((N >> 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() { vector<int> v; int n, i, x = 1, a; cin >> n; for (i = 1; i <= n; i++) { v.push_back(1); while (v.size() > 1 && v.back() == v[v.size() - 2]) { v.pop_back(); v.back()++; } } for (i = 0; i < v.size(); 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
n = int(input()) arr = [1] for i in range(n-1): arr.append(1) while len(arr)>=2 and arr[-1]==arr[-2]: arr[-2] += 1 del 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
import java.util.Scanner; public class WunderFundRound2016_1 { public static void main(String[] args) { int[] powers = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536}; Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // boolean found = false; int i=0; while (i<17){ i...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def solve(): n = bin(int(input()))[-1:1:-1] b = [i + 1 for i in range(len(n)) if n[i] == '1'] print(' '.join(map(str, b[::-1]))) if __name__ == "__main__": solve()
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> v; int z = 1; while (n != 0) { if (n % 2 == 1) { v.push_back(z); } n /= 2; z++; } reverse(v.begin(), v.end()); for (int i = 0; i < v.size(); 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
#include <bits/stdc++.h> int main() { unsigned long long int n, i, j, ans[100001], count; scanf("%lld", &n); count = 0; j = 100000; while (n != 0) { if ((n & 1) == 1) { ans[j] = count + 1; j--; } count++; n = n >> 1; } for (i = j + 1; i <= 100000; i++) { printf("%lld ", ans...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 300020; const int mod = 1000000007; long long int n; stack<long long int> st; int main() { cin >> n; for (long long int i = 1; i <= n; i++) { if (st.empty()) st.push(1); else { if (st.empty()) { st.push(1); continue; ...
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; void a(int n) { int b = 0; if (n == 0) return; else if (n == 1) { cout << "1 "; return; } else { b = (int)(floor(log2(n))); cout << b + 1 << " "; a(n - (int)(pow(2, b))); } } int main() { int n; cin >> n; a(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.util.Scanner; /** * 1/29/16 **/ public class A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] a = new int[100001]; int temp = n; for(int i =0;i < n; i++) { a[i] = temp%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.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Stack; import java.util.StringTokenizer; public class slimes { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nex...
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 from math import acos,asin,atan,sqrt,pi,sin,cos,tan,ceil,floor,log import re from operator import itemgetter as ig #map(int,raw_input().split()) n=input() lis=[] s=0 for i in range(n): lis.append(1) s+=1 while s>1 and lis[-1]==lis[-2]: lis[-2]+=1 lis.pop() 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 n; int base = 1; int state[100000] = {0}, total = 0; int main() { cin >> n; int now = 0; while (now < n) { now++; total++; state[total] = 1; while (state[total] == state[total - 1]) { total--; state[total]++; } } for (int 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.*; import java.util.*; public class Solution { public static void main(String[] args) throws NumberFormatException,IOException{ /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ BufferedReader b = new BufferedReader(new 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
import sys n = int(input(), 10) b = bin(n) l = len(b) for i in b: if i == '1': print(l, end="") if l != 0: print(' ', end="") l = 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
#include <bits/stdc++.h> using namespace std; int n, i, j, a[100005], b[100005], answ, l; vector<int> g; int main() { cin >> n; a[1] = 1; b[1] = 1; if (n == 1) { cout << 1 << endl; return 0; } for (i = 2;; i++) { a[i] = b[i - 1] + 1; b[i] = b[i - 1] + a[i]; if (b[i] > n) break; } 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(raw_input()) row = [ 1 ] for i in range(1, n): row.append(1) while len(row) >= 2 and row[-1] == row[-2]: x = row.pop() row[-1] = x + 1 print(' '.join(map(str, row)))
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; void solve(int n, int x) { if (!n) return; solve(n / 2, x + 1); if (n & 1) cout << x + 1 << ' '; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; solve(n, 0); 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 n; int main() { cin >> n; for (int i = 16; i >= 0; i--) { if ((1 << i) <= n) { cout << i + 1 << " "; n -= (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 n; vector<int> arr; int main() { cin >> n; int ind = 1; while (n) { if (n & 1) { arr.push_back(ind); } n >>= 1; ind++; } for (int i = arr.size() - 1; i >= 0; i--) { cout << arr[i] << " "; } 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
#include <bits/stdc++.h> using namespace std; void solution() { int n; cin >> n; vector<int> ans; ans.clear(); int x = 0; while (n) { x++; if (n & 1) ans.push_back(x); n >>= 1; } reverse((ans).begin(), (ans).end()); for (int i = (0); i < (ans.size()); i++) { if (i) cout << " "; cou...
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() { ios::sync_with_stdio(false); stack<long long> S; int n; cin >> n; vector<long long> V; V.push_back(1); n--; while (n--) { V.push_back(1); int i = V.size() - 1; while (V.size() > 1 && V[i] == V[i - 1]) { long long Val = V[i] + 1...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) curr = 1 result = [] while n > 0: if n % 2 == 1: result.append(curr) n //= 2 curr += 1 print(' '.join(map(str, result[::-1])))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=input() ans=[] if n==1: print 1 elif n==2: print 2 else: i=1 ans.append(1) while n-1: ans.append(1) #print ans if ans[i]==ans[i-1]: while i>=1 and ans[i]==ans[i-1]: ans[i-1]+=1 ans.remove(ans[i]) i-=1 #print i i+=1 n-=1 for i in ans: print i,# your code goes here
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
#a = list(map(int, raw_input().split())) #print a n = int(raw_input()) res = [] for i in range(n): res.append(1) m = -1 for i in range(n): m += 1 res[m] = 1 while m > 0 and res[m] == res[m-1]: m -= 1 res[m] = res[m] + 1 for i in range(m+1): print res[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.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.InputMismatchException; import java.io.IOException; import java.util.Collections; import java.util.ArrayList; import java.io.InputStream; /** * Built using CHelper p...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(raw_input()) a=[] for i in range(n): a.append(1) while len(a)>1 and a[-1]==a[-2]: a.pop() a[-1]+=1 for i in a: print i,
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
a = int(input()) b = [] for i in range(a) : b.append(1) while True: if len(b) > 1 and b[-1] == b[-2]: b[-2] += 1 del b[-1] else: break print(*b)
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.*; import java.util.Stack; import java.util.StringTokenizer; /** * Created by peacefrog on 1/29/16. * Time : 11:06 PM */ public class 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
x=int(input()) i=0 a=[] while x : i=i+1 if x%2!=0: b=(x%2)*i a.append(b) x=x//2 else: x=x//2 a.reverse() for t in range (len(a)): print('{}'.format(a[t]))
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> arr; for (int i = 0; i < n; i++) { arr.push_back(1); for (int j = arr.size() - 1; j >= 0; j--) { if (arr.size() != 1 && arr[j] == arr[j - 1]) { arr.erase(arr.begin() + j); arr[j - 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()) out = [] cur = 1 while n > 0: if n % 2 == 1: out.append(cur) cur += 1 n //= 2 for v in reversed(out): print(v, end=' ') print()
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<long long> v; while (n--) { v.push_back(1); while (v.size() > 1 && v[v.size() - 1] == v[v.size() - 2]) { v[v.size() - 2]++; 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.Scanner; //import TetraHedron.Scanner; public class slimeclimbing { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input =new Scanner(System.in); int n = input.nextInt(); int count=0; ArrayList<Integer> list =new ArrayList...
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(void) { int N; scanf("%i", &N); int i; int dva[30]; dva[0] = 1; for (i = 1; i < 20; i++) { dva[i] = 2 * dva[i - 1]; } int stav = 0; for (i = 19; i >= 0; i--) { if ((N & dva[i]) != 0) { if (stav == 0) printf("%i", i + 1); ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { for (int i = 31; i > -1; --i) if (n & (1 << i)) cout << i + 1 << " "; cout << endl; } 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; void ans(int n) { int p, m; if (n == 0) { return; } else if (n == 1) { printf("1"); return; } else { p = 2; m = 1; while (p <= n) { p *= 2; m++; } p /= 2; printf("%d ", m); ans(n - p); return; } } int main() ...
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) s=s[2:] for i in range(len(s)): if s[i]=='1': print(len(s)-i,end=" ")
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.*; public class CF618A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); ArrayDeque<Integer> stack = new ArrayDeque<Integer>(); for(int i = 0; i < n; i ++) { stack.push(1); while(!stack.isEmpty()) { int at = stack.pop(); if...
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
/** * Created by Omar on 1/29/2016. */ import java.util.*; import java.io.*; public class A { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); //String[] parts=br.rea...
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 = bin(n)[2:] l = [] for i, c in enumerate(b): if c == '1': l.append(len(b) - i) print(' '.join(map(str, l)))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) ls = [] for i in range(n): ls.append(1) try: while ls[-2]==ls[-1]: ls[-2]+=1; ls = ls[:-1] except: pass for j in ls: print(j, end=' ') print()
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; int nums[1000001] = {0}; int i = 0; while (n--) { ++i; ++nums[i]; for (int j = i; j >= 1; --j) { if (nums[j] == nums[j - 1]) { nums[j] = 0; i = j - 1; ++nums[j - 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
# -*- coding: utf-8 -*- # Input num_slimes = int(raw_input()) row = [] for i in xrange(num_slimes): row.append(1) for ii in xrange(len(row)-1): if row[-2] == row[-1]: row[-2] += 1 row.pop() # Ans ans = '' for slime in row: ans = '{0} {1}'.format(ans, slime) print ans
PYTHON
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> const long double pi = acos(-1.0); using namespace std; vector<int> a; int n; int main() { cin >> n; for (int i = 1; i <= n; i++) { a.push_back(1); while (1) { if (a.size() == 1) break; if (a[a.size() - 1] == a[a.size() - 2]) { a.pop_back(); a[a.size() - ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int n, a[100001], i = 0; int main() { cin >> n; while (n != 0) { a[i] = 1; while (1) { if (a[i] == a[i - 1]) { a[i] = 0; i--; a[i] += 1; } else break; } i++; n--; } for (int j = 0; j <= 100000; j++) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; a[0] = -1; int j = 0; for (int i = 0; i < n; i++) { j++; a[j] = 1; while ((a[j] == a[j - 1])) { a[j - 1]++; j--; } } for (int i = 1; i < j + 1; i++) cout << a[i] << ' '; return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int getBit(int num, int pos) { return (num >> pos) & 1; } int setBit(int num, int pos, int val) { if (val == 0) { return num & (~(1 << pos)); } else { return num | (1 << pos); } } int main() { int arr[100000]; int st = 1; arr[0] = 1; int n, i; cin >>...
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
from collections import deque Size = int(input()) List = deque() for i in range(Size): List.append(1) while True: if len(List) > 1 and List[-1] == List[-2]: List.pop() List[-1] += 1 else: break print(*List)
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()) if n == 1: print 1 sys.exit() l = [1] ans = 1 for i in xrange(n-1): l = [1] + l while len(l) > 1: if l[0] == l[1]: del l[0] l[0] += 1 else: break for i in l[::-1]: 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(input()) arr = [1] for i in range(1, n): arr.append(1) while (len(arr) > 1 and arr[-1] == arr[-2]): arr.pop() arr[-1]+=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; struct node { int a, b; bool operator<(const node &p) const { if (b == p.b) return a, p.a; else return b < p.b; } }; int main() { int pp, b, i, j, k, m, n, p, q; string s; while (cin >> n) { deque<int> m1; for (i = 0; i < n; 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 = [] for i in range(n): l.append(1) while len(l) > 1 and l[-1] == l[-2]: x = l.pop() l[-1] += 1 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> using namespace std; const int maxn = 110; int go(int p) { return pow(2, p); } int main() { int n; cin >> n; vector<int> ans; int p = 1; while (n) { if (n % 2) ans.push_back(p); n /= 2; p++; } for (int i = ans.size() - 1; i >= 0; i--) { cout << ans[i] << " "; } ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) s=[] for i in range(20,-1,-1): if n&(1<<i) >0: s+=[str(i+1)] print(" ".join(s))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) slimes = list() for _ in range(n): slimes.append(1) while len(slimes) > 1 and slimes[-1] == slimes[-2]: slimes.pop() slimes[-1] += 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
n=int(input());v=[] t=0;s="" while (n!=0): s+=str(n%2) n//=2 for i in range(len(s)): if (s[i]=="1"): v.append(i+1) for i in range(len(v)-1,-1,-1): print(v[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 math a=[0]*1000000 n=input() i=1 while i <1000000: a[i]=int(math.log(i,2))+1 i*=2 b=bin(n) for i in range(2,len(b)): if b[i]=='1': print a[2**(len(b)-i-1)], #print a[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
def Inspect(): global Slice k = len(Slice) for i in range(k): if Slice[i] != -1: Slice.append(Slice[i]) Slice = Slice[k:] for i in range(len(Slice)-1): if Slice[i] == Slice[i+1]: return False return True n = int(input()) Slice = [1] * n while not(Inspect()...
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 problemA { public static void main(String[] args){ Scanner in = new Scanner(System.in); //int runs = in.nextInt(); // for(int run = 1;run<=runs;run++){ // // } int s = in.nextInt(); String ret = ""; int num = 1; while (s>0){ if(s%2==1){ ret = nu...
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 = [] while n > 0: res.append(n%2) n//=2 ans=[] for i in range(len(res)): if(res[i])>0: ans.append(i+1) ans.reverse() print(' '.join(map(str, 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 = int(input()) v = [] for i in range(0, n): v.append(1) while True: if len(v) > 1 and v[-1] == v[-2]: v.pop() v[-1] += 1 else: break print(*v) # ♥ # امشب مهمون دارم
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n = int(input()) for i in reversed(range(21)): if n & (1 << i) != 0: print(i + 1, end=' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
n=int(input()) for i in range(16,-1,-1): if(n>=2**i): n-=2**i print(i+1,end=' ')
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> int main() { long long int n; double temp, temp2; scanf("%lld", &n); while (n != 0) { temp = log((double)n) / log((double)2); temp2 = (long long int)floor((double)temp); printf("%lld ", (long long int)temp2 + 1); n = n - pow(2, temp2); } return 0; }
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
def process_stack(stk): while len(stk) > 1: last_element = stk.pop() second_last = stk.pop() if last_element != second_last: stk.append(second_last) stk.append(last_element) break else: last_element = last_element + 1 stk.ap...
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 final class SlimeCombining { public static void main(String args[])throws java.lang.Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); OutputStream out=new BufferedOutputStream(System.out); int x=Integer.parseInt(b...
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; vector<int> bit(int x) { stack<int> st; while (x > 0) { st.push(x % 2); x /= 2; } vector<int> res; while (!st.empty()) { res.push_back(st.top()); st.pop(); } reverse(res.begin(), res.end()); return res; } int main() { int n; cin >> n; 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
import java.util.*; public class SlimeCombiningA{ public static void main (String[] args){ Scanner key = new Scanner(System.in); int slices = key.nextInt(); int[] arr = new int[slices]; int k=0; while(slices!=0){ arr[k]+=1; if(k==0){ k++; slices--; } else{ for(int i=k;i>0;i--){ 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
import java.util.*; import java.io.*; public class Codeforces { static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static void newST() throws IOException {st = new StringTokenizer(in.readLine());} static int stInt() {return Integer.parseInt(st.nextToken());...
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 n = int(raw_input()) while n: x = int(math.floor(math.log(n, 2)) + 1) print x, n -= 2**(x - 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()) bit=[] while n>0: bit.append(n%2) n//=2 v=[] for i in range(len(bit)): if bit[i]>0: v.append(i+1) v.reverse() print(' '.join(map(str,v)))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int x, a; cin >> x; a = x; vector<int> v; do { v.push_back(x % 2); x = x / 2; } while (x > 0); for (int i = v.size() - 1; i >= 0; i--) { if (v[i] == 1) { if (a % 2 == 0) { cout << i + 1 << " "; } else { 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() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> a; for (int i = 0; i < n; i++) { a.push_back(1); while (a.size() > 1 && a.back() == a[a.size() - 2]) { a[a.size() - 2]++; a.pop_back(); } } for (auto x : a) { ...
CPP
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#include <bits/stdc++.h> using namespace std; int a[100 * 1000 + 10]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; int cnt = 0; while (n >= 1) { int i = 1; int j = 0; while (i * 2 <= n) { j++; i *= 2; } a[cnt] = j + 1; cnt++; ...
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()) print(" ".join(str(i+1) for i in range(20,-1,-1) if (n&(1<<i)) > 0))
PYTHON3
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
#!/usr/bin/env python3 n = int(input()) k = [] for i in range(0, n): k.append(1) while len(k) > 1 and k[-1] == k[-2]: k[-2] += 1 del k[-1] first = True for i in k: if first: first = False else: print(' ', end='') 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.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.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.Scanner; public class sli { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i=sc.nextInt(); int a[]=new int [i]; int k=0; for(int j=0;j<i;j++) { a[k]=1; for(int p=k-1;p>-1;p--) { if(a[p]==a[p+1]) { a[p]++; a[p+1]=0; } else ...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author Nikhil Pathania */ public class Slime { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int test=In...
JAVA
618_A. Slime Combining
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
2
7
import java.util.Scanner; import java.util.Stack; public class ACM{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Stack<Integer>a = new Stack<>(); a.push(1); n=n-1; while (n-->0) { a.push(1); int temp = a.pop(); while (!a.isEmpty() && a.peek(...
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), cin.tie(NULL), cout.tie(NULL); int n; cin >> n; int num = n; vector<int> v; int cnt = 0; x: for (int i = 0;; i++) { int z = pow(2, i); if (z > num) { break; } if (z <= num) { cnt++; ...
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() s = bin(n)[2:] ans = "" for i in range(len(s)): if s[i] == '1': ans += str(len(s)-i) + " " print ans.strip()
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> v; v.push_back(1); --n; while (n) { if (v[v.size() - 1] == 1) { v[v.size() - 1] = 2; --n; } else { v.push_back(1); --n; } bool h = 1; while (h && v.size() >= 2) { if (v[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
import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import java.io.*; public class A { public static void main(String[] args) { new A().solve(); } FasterScanner in=new FasterScanner(); PrintWriter out=new PrintWriter(System.out); public void solve() { // int tt=in.nextInt(); // loop: ...
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 CFProblemA { public static void main(String[] args){ Scanner input = new Scanner(System.in); int in = input.nextInt(); int[] result = new int[32]; for(int a = 0;a < 32; a++){ result[a] = in%2; in = in/2; } for(int a = 31; a >= 0; a--){ if(result[a] != 0){ ...
JAVA