solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
a,b=map(int,input().split()) num=a for i in range(1000): if a>=b: num+=(a//b) a=a//b+a%b print(num)
7
PYTHON3
a,b=map(int,input().split()) num=a i=a while i>=b: num+=(i//b) i=i-(i//b)*(b-1) print(num)
7
PYTHON3
a,b = map(int,input().split()) c = a cout = 0 while a>=b: cout += a//b a = a//b + a%b print(c+cout)
7
PYTHON3
#include <bits/stdc++.h> int a, b, ans, aux, rem; int main() { scanf("%d %d", &a, &b); while (a != 0) { aux = 0; ans += a; rem += (a % b); if (rem >= b) { aux = rem / b; rem = rem % b; } a = (a / b) + aux; } printf("%d", ans); return 0; }
7
CPP
##############--->>>>> Deepcoder Amit Kumar Bhuyan <<<<<---############## """ Perfection is achieved not when there is nothing more to add, but rather when there is nothing more to take away. """ from __future__ import division, print_function import os,sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def ii(): return int(input()) def si(): return input() def mi(): return map(int,input().strip().split(" ")) def msi(): return map(str,input().strip().split(" ")) def li(): return list(mi()) def dmain(): sys.setrecursionlimit(1000000) threading.stack_size(1024000) thread = threading.Thread(target=main) thread.start() #from collections import deque, Counter, OrderedDict,defaultdict #from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace #from math import log,sqrt,factorial,cos,tan,sin,radians #from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right #from decimal import * #import threading #from itertools import permutations #Copy 2D list m = [x[:] for x in mark] .. Avoid Using Deepcopy import sys input = sys.stdin.readline scan_int = lambda: int(input()) scan_string = lambda: input().rstrip() read_list = lambda: list(read()) read = lambda: map(int, input().split()) read_float = lambda: map(float, input().split()) # from bisect import bisect_left as lower_bound; # from bisect import bisect_right as upper_bound; # from math import ceil, factorial; def ceil(x): if x != int(x): x = int(x) + 1 return x def factorial(x, m): val = 1 while x>0: val = (val * x) % m x -= 1 return val def fact(x): val = 1 while x > 0: val *= x x -= 1 return val # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; ## gcd function def gcd(a,b): if b == 0: return a; return gcd(b, a % b); ## lcm function def lcm(a, b): return (a * b) // math.gcd(a, b) def is_integer(n): return math.ceil(n) == math.floor(n) ## nCr function efficient using Binomial Cofficient def nCr(n, k): if k > n: return 0 if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return int(res) ## upper bound function code -- such that e in a[:i] e < x; ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0 and n > 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0 and n > 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b; # find function with path compression included (recursive) # def find(x, link): # if link[x] == x: # return x # link[x] = find(link[x], link); # return link[x]; # find function with path compression (ITERATIVE) def find(x, link): p = x; while( p != link[p]): p = link[p]; while( x != p): nex = link[x]; link[x] = p; x = nex; return p; # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] prime[0], prime[1] = False, False p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime # Euler's Toitent Function phi def phi(n) : result = n p = 2 while(p * p<= n) : if (n % p == 0) : while (n % p == 0) : n = n // p result = result * (1.0 - (1.0 / (float) (p))) p = p + 1 if (n > 1) : result = result * (1.0 - (1.0 / (float)(n))) return (int)(result) def is_prime(n): if n == 0: return False if n == 1: return True for i in range(2, int(n ** (1 / 2)) + 1): if not n % i: return False return True def next_prime(n, primes): while primes[n] != True: n += 1 return n #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e5 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# spf = [0 for i in range(MAXN)] # spf_sieve(); def factoriazation(x): res = [] for i in range(2, int(x ** 0.5) + 1): while x % i == 0: res.append(i) x //= i if x != 1: res.append(x) return res ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) def factors(n): res = [] for i in range(1, int(n ** 0.5) + 1): if n % i == 0: res.append(i) res.append(n // i) return list(set(res)) ## taking integer array input def int_array(): return list(map(int, input().strip().split())); def float_array(): return list(map(float, input().strip().split())); ## taking string array input def str_array(): return input().strip().split(); def binary_search(low, high, w, h, n): while low < high: mid = low + (high - low) // 2 # print(low, mid, high) if check(mid, w, h, n): low = mid + 1 else: high = mid return low ## for checking any conditions def check(beauty, s, n, count): pass #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); alphs = "abcdefghijklmnopqrstuvwxyz".upper() ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### from itertools import permutations import math import bisect as bis import random import sys import collections as collect def solve(): a, b = read() s = 0 rem = 0 while a > 0: s += a a += rem rem = a % b a //= b print(s) # region fastio # template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") def print(*args, **kwargs): """Prints the values to a stream, or to sys.stdout by default.""" sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout) at_start = True for x in args: if not at_start: file.write(sep) file.write(str(x)) at_start = False file.write(kwargs.pop("end", "\n")) if kwargs.pop("flush", False): file.flush() if sys.version_info[0] < 3: sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout) else: sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # endregion if __name__ == "__main__": #read() for i in range(1): solve() #dmain() # Comment Read() # fin_time = datetime.now() # print("Execution time (for loop): ", (fin_time-init_time))
7
PYTHON3
n,b=map(int,input().split()) if(b==1): print("You Enter A Bad Number Computer Will Compute For True!!") if(b==0): print("You Enter A Bad Number Computer Will Have Errors!!") p=n e=0 n2=0 while(n//b>0): while(n>=b): p=p+(n//b) n2=(n//b) e=e+(n%b) n=n2 e=e+(n%b) n=e e=0 print(p)
7
PYTHON3
a,b = [int(s) for s in input().split()] p, t = 0, 0 while a > 0: a -= 1 p += 1 t += 1 if p%b == 0: a += 1 p = 0 print (t)
7
PYTHON3
a,b = map(int,input().split(' ')) Candels = a Hours = 0 while Candels != 0: Hours +=1 Candels -=1 if Hours % b == 0: Candels +=1 print(Hours)
7
PYTHON3
a, b = map(int, input().split()) h = 0 c = 0 while(a > 0): h += 1 a -= 1 c += 1 if c == b: a += 1 c = 0 print(h)
7
PYTHON3
import sys sys.setrecursionlimit(280000) a, b = map(int, input().split()) ans = 0 dead = a while a>=b: ans += a - a % b dx = a-a%b a-= dx a+= dx//b print(ans+a)
7
PYTHON3
a = list(map(int,input().strip().split())) m = a[0] n = a[1] c = 0 while m >= n: c += m//n m = m//n + m%n print(c+a[0])
7
PYTHON3
list = [int (x) for x in input().split()] a = list[0] b = list[1] hours =0 burn =0 if a<b: print(a) else: while a : hours+=1 a-=1 burn+=1 if burn==b: burn=0 a+=1 print(hours)
7
PYTHON3
a,b=[int(x) for x in input().split()] sum=a while a>=b: sum+=a//b a=(a//b)+(a%b) sum=int(sum) print(sum)
7
PYTHON3
''' Good Bye 2013A @autor Yergali B ''' a,b=map(int,input().split()) print((a*b-1)//(b-1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, sum = 0; cin >> a >> b; while (a >= b) { sum += a - a % b; a = (a - a % b) / b + a % b; } cout << sum + a << endl; return 0; }
7
CPP
a,b=map(int,input().split()) cnt=a while a>=b: baqimande=a%b a=a//b cnt+=a a+=baqimande print(cnt)
7
PYTHON3
# 0379A - New Year Candles # https://codeforces.com/problemset/problem/379/A # https://atcoder.jp/contests/arc011/tasks/arc011_1 def main(): a, b = tuple(map(int, input().rstrip().split())) ans = a while a >= b: ans += a // b a = a // b + a % b print(ans) if __name__ == "__main__": main()
7
PYTHON3
#include <bits/stdc++.h> int main() { int a, b, d, e, c, f; scanf("%d%d", &a, &b); d = a; while (a >= b) { d = d + a / b; a = a / b + a % b; } printf("%d\n", d); return 0; }
7
CPP
a, b = map(int, input().split()) k = 0 while a != 0: a -= 1 k += 1 if k % b == 0: a += 1 print(k)
7
PYTHON3
a,b=input().split() a=int(a) p=a b=int(b) n=a while(n>0): n=a//b a=n+a%b p=p+n print(p)
7
PYTHON3
candles, reforge = map(int, input().split()) result = candles while candles >= reforge: candles_left = candles % reforge candles = candles // reforge result += candles candles += candles_left print(result)
7
PYTHON3
a=list(map(int,input().split())) can=a[0] hou=0 while True: can-=1 hou+=1 if hou%a[1]==0: can+=1 if can==0: break print(hou)
7
PYTHON3
a,b=map(int,input().split()) sum1=a while a>=b: re=int(a/b) a=re+a%b sum1=sum1+re print(sum1)
7
PYTHON3
ln = input().split(" ") a = int(ln[0]) b = int(ln[1]) print(a + int((a-1)/(b-1)))
7
PYTHON3
n,m=map(int,input().split()) print(n+(n-1)//(m-1))
7
PYTHON3
def get_hours(n, b, remaining): if n + remaining < b: return n else: return n + get_hours((n + remaining) // b, b, (n + remaining) % b) a, b = map(int, input().split()) print(get_hours(a, b, 0))
7
PYTHON3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 13 08:13:14 2017 @author: lawrenceylong """ c,b=map(int,input().split()) print((c*b-1)//(b-1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int A, B; cin >> A >> B; long long int total = A; while (true) { long long int div = A / B; total += div; A = div + (A % B); if (A < B) break; } cout << total << endl; return 0; }
7
CPP
a, b = map(int, input().split()) i = 0 j = a ans = a while j >= b: now = j//b ans += now j %= b j += now print(ans)
7
PYTHON3
n,m=map(int,input().split()) k=n//m n=n+k t=n//m while t-k>=m or t-k>0: n=n+t-k k=t t=n//m n=n+t-k print(n)
7
PYTHON3
n,m=(int(i) for i in input().split()) d=0 while d!=n: d+=1 if d%m==0: n+=1 print(d)
7
PYTHON3
a,b = [int(x) for x in input().split()] n = a m = a r = 0 p = 0 while m > b-1: r = m - int(m/b)*b p = int(m/b) m = p + r n = n + p print(n)
7
PYTHON3
def new_year_candles(c, d): x = c while c >= d: x += (c // d) c = (c// d) + (c % d) return x # -------------------------------------------------------------- if __name__ == '__main__': f = lambda: map(int, input().split()) a, b = f() print(new_year_candles(a,b))
7
PYTHON3
sa=input().split(' ') a=int(sa[0]) b=int(sa[1]) candles=0 lefts=0 while a>0: candles+=1 a-=1 lefts+=1 if lefts==b: a+=1 lefts=0 print(candles)
7
PYTHON3
a, b = map(int, input().split()) ans = a left = 0 while(1): burn = a//b left += a%b a = burn if left>=b: a += 1 left = left%b if a==0: break ans += a print(ans)
7
PYTHON3
a,b=input().split() a=int(a) b=int(b) count=a while a//b>0: count+=(a//b) a=a//b+(a-((a//b)*b)) print(count)
7
PYTHON3
a,b=map(int,input().split()) r=a while a>a%b: r+=a//b a=a//b+a%b print(r)
7
PYTHON3
a,b=input().split() a=int(a) b=int(b) d=a//b c=a+d e=1 while d>=1: a= a//b+ a%b d=a//b c=c+d print(c)
7
PYTHON3
a,b=map(int,input().split()) time=a for x in range(1001): if a//b >=1: time+=a//b a=a//b+a%b if a<1: break print(time)
7
PYTHON3
a, b = map(int, input().split(' ')) out = a nam = 0 while a>0: a, nam = divmod(a+nam, b) out += a print(out)
7
PYTHON3
# your code goes here a,b=map(int,input().split()) print((a*b-1)//(b-1))
7
PYTHON3
a, b = map(int, input().split()) c = a while a >= b: c += a // b a = a % b + a // b print(c)
7
PYTHON3
a, b = map(int, input().split()) counter = a temp = a while temp//b != 0: counter += temp//b temp = temp//b if temp%b==0 else temp//b + temp%b print(counter)
7
PYTHON3
a, b = map(int, input().split()) ans = a ost = 0 while a >= b: ost = a % b a = a // b ans += a a += ost print(ans)
7
PYTHON3
d = input().split() a,b = int(d[0]), int(d[1]) y = 0 x = 0 while a >0: a-=1 x+=1 y+=1 if y == b: a+=1 y=0 print(x)
7
PYTHON3
s=[int(x) for x in input().split()] a=s[0] b=s[1] t=0 for i in range(10000000): if a>=b: m=int(a/b) c=a-m*b t+=m*b a=m+c elif a>=0 and a<b: t+=a break print(t)
7
PYTHON3
import sys in_str = (sys.stdin.readline()).split() a = int(in_str[0]) b = int(in_str[1]) hours = a while(a >= b): ost = int(a % b) a = int(a / b) hours += int(a) a += ost print(hours)
7
PYTHON3
a,b=map(int,input().split()) s=a while(a>=b): s+=a//b a=a//b +a%b print(s)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, count; cin >> a >> b; count = a; if (b > a) { cout << count << endl; return 0; } while (a > 1 && a >= b) { count += a / b; a = a / b + a % b; } cout << count << endl; return 0; }
7
CPP
a, b = map(int, input().split()) res = a while 1: res += a//b a = a//b + a%b if a < b: break print(res)
7
PYTHON3
z,zz=input,lambda:list(map(int,z().split())) fast=lambda:stdin.readline().strip() zzz=lambda:[int(i) for i in fast().split()] szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz()) from string import * from re import * from collections import * from queue import * from sys import * from collections import * from math import * from heapq import * from itertools import * from bisect import * from collections import Counter as cc from math import factorial as f from bisect import bisect as bs from bisect import bisect_left as bsl from itertools import accumulate as ac def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2)) def prime(x): p=ceil(x**.5)+1 for i in range(2,p): if (x%i==0 and x!=2) or x==0:return 0 return 1 def dfs(u,visit,graph): visit[u]=1 for i in graph[u]: if not visit[i]: dfs(i,visit,graph) ###########################---Test-Case---################################# """ """ ###########################---START-CODING---############################## num=1 #num=int(z()) for _ in range ( num ): a,b=zz() ans=a c=a while True: if c>=b: ans+=c//b c=c//b+(c%b) else: break print(ans)
7
PYTHON3
a , b = map(int , input().split(' ')) res = a rem = a while(rem>=b): x = rem//b rem = rem%b+x res +=x print(res)
7
PYTHON3
a, b = [int(i) for i in input().split()] g = a p = 0 l = 0 while True: l += g p += g g = int(p / b) p -= b * g if p < b and not g: print(l) exit(0)
7
PYTHON3
a,b=map(int,input().split()) s=a while a//b>0: s=s+a//b a=a%b+a//b print(s)
7
PYTHON3
a,b=map(int,input().split()) ans=0 c=0 while a!=0: ans+=a c+=a a=c//b c%=b print(ans)
7
PYTHON3
def fun(): a,b=map(int,input().split()) cnt=0 while cnt<a: cnt+=1 if cnt%b==0: a+=1 print(a) fun()
7
PYTHON3
d = [int(x) for x in input().split(' ')] h = 0 while(d[0]>0): h+=1 d[0]-=1 if(h%d[1]==0): d[0]+=1 print(h)
7
PYTHON3
n,m=map(int,input().split()) d=1 while(d<=n): if d%m==0: n+=1 d+=1 print(d-1)
7
PYTHON3
q,w=map(int,input().split()) count=q while q//w: count+=q//w q=q//w+q%w print(count)
7
PYTHON3
import math a,b=map(int,input().split()) ans=a rem=0 while(a>=b): tmp=a//b ans=ans+tmp rem=a%b a=tmp+rem print(ans)
7
PYTHON3
a,b=(int(i) for i in input().split()) print((a*b-1)//(b-1))
7
PYTHON3
n, k = map(int, input().split()) ans = n while n>=k: ans += int(n/k) n = int(n/k) + int(n%k) #print(n) print(int(ans))
7
PYTHON3
a, b = map(int, input().split()) pr = 0 time = 0 while a > 0: time += 1 a = a-1 pr += 1 if pr == b: a += 1 pr = 0 print(time)
7
PYTHON3
n, m = map(int, input().split()) d = n*m//(m-1) print(d - (d % m == 0))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int a, b; void solve() { int tot{a}; while (a / b != 0) { tot += a / b; a = a / b + a % b; } cout << tot; } int main() { cin >> a >> b; solve(); }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int sum = 0; sum += n; while (1) { sum = sum + n / m; n = n / m + n % m; if (n < m) break; } cout << sum << endl; }
7
CPP
a, b = [int(x) for x in input().split()] cnt = a new = 1 if a % b == 0: while new > 0: new = a // b cnt += a // b a = a // b + a % b print(cnt) else: while new > 0: new = a // b cnt += a // b rem = a % b a = a//b + rem print(cnt)
7
PYTHON3
a,b=[int(x) for x in input().split()] d=0 out=0 while a>0: a-=1 d+=1 out+=1 if out%b==0: a+=1 if a==0: print(d)
7
PYTHON3
params = input() candles,b = [int(i) for i in params.split(' ')] hours = candles burned = candles while (burned >= b): candles = burned // b burned = (burned%b) + candles hours += candles print(hours)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const long long int M = 1e9 + 7; int main() { long long int a, b; cin >> a >> b; long long int ans = 0; while (a >= 1) { if (a >= b) { ans += b; a = a - b + 1; } else { ans += a; a = 0; } } cout << ans << endl; return 0; }
7
CPP
ab = input().split(" ") for i in range(len(ab)): ab[i] = int(ab[i]) a = ab[0] b = ab[1] counter = a while a>0: a = a-b+1 counter += 1 counter -= 1 print(counter)
7
PYTHON3
q,w=map(int,input().split()) s=q e=0 while (q)//w>0: s+=q//w q=q//w+q%w print(s)
7
PYTHON3
a,b = map(int,input().split()) flag = True count = a while flag != False: if(a >= b): count = count + a//b a = a // b + a % b else: flag = False print(count)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, r = 0; cin >> a >> b; int rv = 0; while (a) { rv += a; r += a; a = r / b; r %= b; } cout << rv << endl; return 0; }
7
CPP
a,b =map(int,input().split()) t=0 r=0 while a: t+=a r+=a a,r = (r//b,r%b) print(t)
7
PYTHON3
a,b=map(int,input().split()) h=a while h>1: h=h/b a=a+h print(int(a))
7
PYTHON3
# a, b = map(int, input().split()) # # hour = 0 # new_candle = a // b # new_hour = a % b # # while a > 0: # hour += 1 # a -= 1 # if a == 0: # hour += new_candle # if new_hour == 0 and a == 0 and new_candle % b == 0: # hour += 1 # print(hour) a, b = map(int, input().split()) hour = 0 while a > 0: hour += 1 a -= 1 if hour % b == 0: a += 1 print(hour)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0, a1 = 0; cin >> a >> b; while (a > 0) { c += a; a1 += a; a = 0; a += a1 / b; a1 %= b; } cout << c; return 0; }
7
CPP
a, b = input().split() a, b = int(a), int(b) x = 0 while a >= b: x += a - a % b a = a // b + a % b x += a print(x)
7
PYTHON3
a, b = map(int, input().split()) hours = 0 left = a while left > 0: hours += 1 left -= 1 if hours % b == 0: left += 1 print(hours)
7
PYTHON3
a, b = map(int, input().split()) s = 0 r = 0 while a: s += a q = (a + r) // b r = (a + r) % b a = q print(s)
7
PYTHON3
a,b=list(map(int,input().split())) l=[] c=a while a>=b: q=a//b c+=q r=a%b a=q+r print(c)
7
PYTHON3
a,b=[int(x) for x in input().split()] hours=0 while(a>=b): hours=hours+(a//b)*b a=a//b + a%b else: hours=hours+a print(hours)
7
PYTHON3
a,b = list(map(int,input().split())) h = a while(int(a/b) >= 1): h = h+int(a/b) a = int(a/b)+a%b print(h)
7
PYTHON3
a,b=map(int,input().split()) d=a while a>=b: d=d+a//b a=a//b+a%b print(d)
7
PYTHON3
n=list(map(int,input().split())) a=n[0] b=n[1] candles=0 count=0 while(a!=0): candles+=1 count+=1 a-=1 #print(candles,count) if candles==b: a+=1 candles=0 print(count)
7
PYTHON3
a, b = [int(i) for i in input().split()] hours = a sub = a remain = 0 while (sub + remain) // b > 0: curr = sub sub = (sub + remain) // b remain = (curr + remain)% b hours += sub print(hours)
7
PYTHON3
a,b=map(int,input().split()) k=0 while a>0: k+=1 a-=1 if k%b==0: a+=1 print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int sum = a; int x = a; while (x) { x = a / b; sum += x; a = x + (a % b); } cout << sum << endl; return 0; }
7
CPP
a,b=input().split() a=int(a) b=int(b) counter=a while a >= b: counter+=int(a/b) a=a%b+int(a/b) print(counter)
7
PYTHON3
s,n=map(int,input().split());print((s-1)//(n-1)+s)
7
PYTHON3
a, b = [int(x) for x in input().split()] hours = a while a > 0: hours += a//b a = a//b + a%b if a <= b: if a == b: hours += 1 break print(hours)
7
PYTHON3
q = input().split(' ') a = int(q[0]) b = int(q[1]) c = a o = a while o >= b: c += o // b o = o % b + o // b print(c)
7
PYTHON3
x,b=map(int,input().split()) print((x*b-1)//(b-1))
7
PYTHON3
num=input().split() a=int(num[0]) b=int(num[1]) n=a while a>=b: n+=a//b a=a//b+a%b print(n)
7
PYTHON3
x,y = map(int,input().split()) print (x+int((x-1)/(y-1)))
7
PYTHON3
a,b=[*map(int,input().split())] c=a+(a-1)//(b-1) print(c)
7
PYTHON3
from sys import stdin, stdout a,b = stdin.readline().split() a, b = [int(a), int(b)] print(a+ ((a-1)//(b-1)))
7
PYTHON3
a,b=[int(x) for x in input().split()] q=0 s=0 while a>0: s+=a q+=a a=q//b q%=b print(s)
7
PYTHON3
a,b=map(int,input().split()) x=a while a>=b: x=x+a//b a=a//b +a%b print(x)
7
PYTHON3