solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
a, b = map(int, input().split()) hour = a while a // b > 0: hour += a // b a = a // b + a % b print(hour)
7
PYTHON3
#include <bits/stdc++.h> int main() { int a, b; scanf("%d %d", &a, &b); int hours = a; int surplus; int t = 0; while (a >= b) { surplus = a % b; a /= b; hours += a; a += surplus; } printf("%d", hours); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b, s = 0, c; cin >> a >> b; s = a; while (1) { c = a / b; a = c + (a % b); s += c; if (a < b) break; } cout << s << endl; return 0; }
7
CPP
if __name__ == '__main__': a, b = input().strip('\n\r\t ').split(' ') a = int(a) b = int(b) avail = a burned = 0 count = 0 while avail > 0: count += 1 avail -= 1 burned += 1 tmp = burned // b avail += tmp burned -= tmp * b print(count)
7
PYTHON3
a,b = map(int,input().split()) hours = a while a // b >= 1: hours += a // b a = a // b + a % b print(hours)
7
PYTHON3
a,b=map(int,input().split()) c=a d=a while c>=b: f=c//b c=f+c-f*b d=d+f print(d)
7
PYTHON3
l = input().split(' ') a, b, mori, hour = int(l[0]), int(l[1]), 0, 0 while a > 0 or mori >= b: if mori >= b: mori -= b a += 1 a -= 1 hour += 1 mori += 1 print(hour)
7
PYTHON3
c=list(map(int,input().split())) a=c[0] b=c[1] h=a while a>=b: if a%b!=0: h+=a//b a=a//b+a%b else: h+=a/b a=a/b print(int(h))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, div, mod; scanf("%d%d", &a, &b); int sum = a; while (a >= b) { div = (a / b); sum = sum + div; mod = (a % b); a = (div + mod); } printf("%d\n", sum); }
7
CPP
#include <bits/stdc++.h> using namespace std; int calc2(int r, int b) { static int ans2 = 0; static int r2 = 0; if (r >= b) { ans2 += r / b; r2 += r % b; calc2(r / b, b); } else { r2 += r; ans2 += r2 / b; } return ans2; } int calc(int a, int b) { static int ans = 0; static int r = 0; if (a >= b) { ans += a / b; r += a % b; calc(a / b, b); } else { r += a; if (r >= a) ans += calc2(r, b); } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b; cin >> a >> b; cout << calc(a, b) + a; return 0; }
7
CPP
a, b = list(map(int, input().split(' '))) l, h = 0, 0 while a > 0: h += a l += a a = l // b l -= l // b * b print(h)
7
PYTHON3
a, b = [int(i) for i in input().split()] t = 0 burnt = 0 while a: a -= 1 t += 1 burnt += 1 if burnt == b: burnt = 0 a += 1 print(t)
7
PYTHON3
# -*- coding: utf-8 -*- """ Created on Fri Jan 4 16:09:29 2019 @author: Nishant Mittal aka nishantwrp """ a,b=map(int,input().split()) left = 0 current = a ans = 0 while current is not 0: ans += current c = current current = int((current+left)/b) left = (c+left)%b print(ans)
7
PYTHON3
# You # Dont read my code full , n = map(int,input().split()) half , ans = 0,0 ans += full half += full while half // n > 0: full = half // n half = half % n ans += full half += full print(ans)
7
PYTHON3
a,b=map(int,input().strip().split()) c=d=0 while(a+d): a-=1 c+=1 if(c%b==0): d+=1 print(c)
7
PYTHON3
n=[int(x) for x in input().split()] count=n[0] while n[0]>=n[1]: count=count+int((n[0]/n[1])) n[0]=(n[0]%n[1])+int((n[0]/n[1])) print(count)
7
PYTHON3
a,b=input().split() a=int(a) b=int(b) total_hours_left=a hours_burned=0 burned_candles=0 while total_hours_left>0: hours_burned+=1 total_hours_left-=1 burned_candles+=1 if burned_candles==b: total_hours_left+=1 burned_candles=0 print(hours_burned)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int a, b; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> a >> b; long long int ans = 0; while (a > 0) { a--; ans++; if (ans % b == 0) a++; } cout << ans << '\n'; return 0; }
7
CPP
a, b = map(int, input().split()) x = cnt = 0 while a > 0: a -= 1 cnt += 1 x += 1 if x % b == 0: a += 1 print(cnt)
7
PYTHON3
s = list(map(int,input().split())) count=0 while s[0] !=0: s[0]-=1 count+=1 if count%s[1]==0: s[0]+=1 print(count)
7
PYTHON3
a_b = [int(x) for x in input().split()] a = a_b[0];b=a_b[1] print(a+(a-1)//(b-1))
7
PYTHON3
n,m=map(int,input().split()) i=1 while(n!=0): n-=1 if(i%m==0): n+=1 i+=1 print(i-1)
7
PYTHON3
a, b = map(int, input().split()) count = a while a >= b : c = a//b count += c a = a//b + a%b print(count)
7
PYTHON3
n, m = map(int, input().split()) x=n def loop(n, m): global x while n>=m: if n%m==0: x += n//m return loop(n//m, m) else: y = n//m + n%m x += n//m return loop(y, m) loop(n, m) print(x)
7
PYTHON3
n, m = [int (i) for i in input().split()] ctr = 0 while (n!=0): ctr += 1 n -= 1 if (ctr %m == 0): n+=1 print (ctr)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, sum, mod; cin >> a >> b; sum = a; while (a >= b) { int div = a / b; sum = sum + div; mod = a % b; a = mod + div; } cout << sum; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b, sum = 0; cin >> a >> b; sum += a; while ((a / b) > 0) { if (a % b == 0) { sum += a / b; a /= b; } else { sum += a / b; a = (a / b) + a % b; } } cout << sum; }
7
CPP
n,m=map(int, input().split()) q=n r=0 w=n while w>=m: q+=w//m w=w//m+(w-(w//m)*m) print (q)
7
PYTHON3
a,b=map(int,input().split()) candles=a leftout=a while(leftout>=b): candles+=(leftout)//b leftout=(leftout)%b+(leftout)//b print(candles)
7
PYTHON3
#include <bits/stdc++.h> int main() { int a, b; std::cin >> a >> b; int hours = 0; int used = 0; while (a != 0) { --a; ++used; ++hours; if (used == b) { ++a; used = 0; } } std::cout << hours << std::endl; return 0; }
7
CPP
#include <bits/stdc++.h> int main() { int a, b, m, s = 0; scanf("%d %d", &a, &b); s = a; while (1) { m = a / b; a = m + (a % b); s += m; if (a < b) break; } printf("%d", s); return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int res = n; while (n >= m) { res += (n / m); n = (n / m) + (n % m); } cout << res << endl; }
7
CPP
a, b = [int(i) for i in input().split()] ans = 0 c = 0 while a > 0: ans += a a, c = (a + c) // b, (a + c) % b print(ans)
7
PYTHON3
a,b=map(int, input().split()) k=a while a>=b: m=a//b a%=b a+=m k+=m print(k)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; signed main() { long long a, b; cin >> a >> b; long long p, q; long long count = a; while (a >= b) { p = a / b; count += p; q = a % b; a = q + p; } cout << count << endl; return 0; }
7
CPP
ab = input().split() a = int(ab[0]) b = int(ab[1]) c=a while(a>=b): c += a//b div = a//b rem = a%b a = div+rem print(c)
7
PYTHON3
a,b=map(int,input().split()) def light(wentOut,b): if wentOut<b: return 0 newCandle=int(wentOut/b) left=wentOut%b return newCandle+light(newCandle+left,b) print(a+light(a,b))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ans = 0; cin >> a >> b; if (a >= b) { ans = a; while (a >= b) { ans += (a / b); a = (a / b) + a % b; } cout << ans << endl; } else { cout << a << endl; } }
7
CPP
candle, new_candle = map(int, input().split()) burnt_candles = 0 hours = 0 while candle > 0: burnt_candles += 1 candle -= 1 if burnt_candles == new_candle: burnt_candles = 0 candle += 1 hours += 1 print(hours)
7
PYTHON3
if __name__ == "__main__": a,b=map(int,input().split()) r=a while a>=b: c=int(a/b) r+=c a=c+a%b print(r)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int count = a; int num_of_candles = a, went_out = 0; while (went_out >= 0) { went_out += num_of_candles; if (went_out / b == 0) break; num_of_candles = went_out / b; went_out -= b * num_of_candles; count += num_of_candles; } cout << count << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, s, k; cin >> a >> b; s = a; while (1) { c = a / b; a = c + (a % b); s += c; if (a < b) break; } cout << s; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int div = a / b; int mod = a % b; int ans = 0, temp = 0; bool flag = false; while (div + mod >= b) { flag = true; ans += div; temp = mod; mod = (div + mod) % b; div = (div + temp) / b; } ans += div; if (flag == true) cout << ans + a; else cout << div + a; return 0; }
7
CPP
a, b=map(int,input().split()) t=0 s=0 while a>0: t+=1 s+=1 a-=1 if s==b: a+=1 s=0 print(t)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, t1, t2, res; cin >> a >> b; res = a; for (;;) { t1 = a / b; res = res + t1; t2 = a % b; if (t1 + t2 > 0) { a = t1 + t2; } if (a / b == 0) { break; } } cout << res << endl; }
7
CPP
n,m=map(int,input().split()) x=n while(int(n)): n=n/m x+=n print(int(x))
7
PYTHON3
a,b=map(int,input().split()) import math print(math.ceil(a*b/(b-1))-1)
7
PYTHON3
__author__ = 'Utena' import math n,m=map(int,input().split()) t=0 while True: if n>=m: t+=(n-(n%m)) n=(n%m)+math.floor(n/m) else: t+=n print(t) break
7
PYTHON3
a,b=map(int,input().split()) k=a t=a h=0 while(t>=b): k+=int(t/b) h=int(t%b) t=int(t/b) #print(t) t+=h print(k)
7
PYTHON3
[a,b] = [int(x) for x in input().split()] candle = a leftover = 0 day = 0 while candle > 0: day += 1 candle -= 1 leftover +=1 if leftover == b: candle += 1 leftover = 0 print(day)
7
PYTHON3
a,b=list(map(int,input().split())) s=0 while a-b>=0: t=a//b a-=t*b-t s+=t*b print(s+a)
7
PYTHON3
a, b = map(int, input().split()) hours = a while a // b > 0: hours += a // b a = a // b + a % b print(hours)
7
PYTHON3
a, b = list(map(int, input().split())) tot = a rem = a while(rem >= b): a = rem//b rem -= a*b tot+=a rem+=a print(tot)
7
PYTHON3
a,b=[int(x) for x in input().split()] hours=a c=a//b while c>0: hours+=c a=a//b+a%b c=a//b print(hours)
7
PYTHON3
a,b=map(int,input().split()) time=a while(a>=b): time+=a//b a=a//b+(a%b) print(time)
7
PYTHON3
s=input().split() n=int(s[0]) x=int(s[1]) t=0 result=0 while n>0: n-=1 result+=1 t+=1 if t==x: n+=1 t-=x print(result)
7
PYTHON3
a, b = map(int, input().split()) k = a while a >= b: os = a % b a //= b k += a a += os print(k)
7
PYTHON3
a, b = map(int, input().split()) days = 0 while a-b >= 0: a = a-b+1 days = days + b print(days + a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int s = 0; while (n != 0) { s++; n--; if (s % m == 0) n++; } cout << s; }
7
CPP
n,k=map(int,input().split()) q=0 w=n r=0 while w>0: r=r+(w%k) if r>=k: z=r%k r=r//k q=q+r r=r+z w=w//k q=q+w print(n+q)
7
PYTHON3
#include <bits/stdc++.h> int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { if (i % m == 0) n++; } printf("%d", n); return 0; }
7
CPP
# h1,a1 = map(int, input().split()) # h2,a2 = map(int, input().split()) # t = 0 # k = 1 # while h2 > 0: # h2 -= a1 # t += 1 # while h1 > 0: # h1 -= a2 # k += 1 # if k > t: # print("Bandergolf") # elif k < t: # print("Bendaril") # # a,b,l,n = map(int, input().split()) # o = 2*l+(2*n-1)*a+2*(n-1)*b # print(o) # # a,b,c,d = map(int, input().split()) # if d <= b: # print(a) # else: # print(a + (d - b) * c) # # # # # # print(1) # print(3) # print(4) # if n[j][i+5].isalpha(): # if n[j][i+5].isalpha(): # if n[j][i+5].isdigit(): # print(2) # if n[j][i+4].isalpha(): # if n[j][i+4].isalpha(): # if n[j][i+4].isdigit(): # if n[j][i+4].isdigit(): # if n[j][i+3].isdigit(): # if n[j][i+3].isdigit(): # if n[j][i+3].isdigit(): # if n[j][i+3].isdigit(): # if n[j][i+2].isdigit(): # if n[j][i+2].isdigit(): # if n[j][i+2].isdigit(): # if n[j][i+2].isdigit(): # if n[j][i+1].isalpha(): # if n[j][i+1].isalpha(): # if n[j][i+1].isdigit(): # if n[j][i+1].isdigit(): # print(0) # a.append(i) # count = 0 # d.append('.') # else: # i = i * -1 # if n[j][i].isalpha(): # if n[j][i].isalpha(): # if n[j][i].isalpha(): # if n[j][i].isdigit(): # o+= int(n[i]) * n[i+1] # o+=int(t)*n[i+2] # o+=n[i] # p+=1 # print(count) # print(o) # print(o+c) # print(o+c+1) # t=n[i] + n[i+1] # a-=1 # a-=1 # b-=1 # b-=1 # c-=1 # count += 1 # count += w[t] # d.append(n[i]) # d.pop(-1) # del otvet[t] # e = x2 - x1 # else: # for i in range(len(n)): # g += c[t] # i+=1 # if count == 3: # if i < 0: # if i == 0: # if n[i].isalpha(): # if n[i].isdigit() and n[i+1].isdigit(): # if n[i].isdigit(): # if o + c >= 0: # if t == t1: # m = m - n # n = y2 - y1 # n.append(str(input())) # n1 += i # o += m / 2 # o += m / 2 + 1 # o = (w[i] / c[i]) # o = a-b-1 # o = o * g[i] # o = o * n # o = o * n # otvet.append(o) # p+=i*2 # print(a-b+c) # print(g) # print(t) # s = y1 - y2 # t = otvet.index(max(otvet)) # t = str(i) # t+=1 # t+=1 # t+=1 # t+=1 # t+=1 # t1 = t[::-1] # w = x1 - x2 # a = [] # a = int(input()) # a = int(input()) # b = int(input()) # b = int(input()) # c = int(input()) # c = int(input()) # c = list(map(int,input().split())) # count = 0 # count = 0 # count = 0 # d = [] # e= 0 # else: # else: # else: # else: # for i in d: # for i in g: # for i in l: # for i in range(0,3): # for i in range(3): # for i in range(k): # for i in range(len(n)): # for i in range(len(n)): # for j in range(len(n)): # from collections import deque # g = 0 # g = list(map(int, input().split())) # g.sort(reverse=True) # i = 0 # if a-b<=0: # if a>0 and a-b>=1: # if len(n) % 3 == 0: # if m % 2 == 0: # if n % 2 == 0: # if x1 < x2: # if y1 < y2: # l = list(map(int, input().split())) # m = int(input()) # m = int(input()) # n = [] # n = input() # n = input() # n = int(input()) # n = int(input()) # n = int(input()) # n = int(input()) # n = int(input()) # n,k = map(int, input().split()) # n1 = '' # n= 0 # o = '' # o = (e * 'e')+(w*'w')+(n*'n')+(s*'s') # o = 0 # o = 0 # o = 1 # otvet = [] # p = 0 # print(a[n]) # print(g) # print(int(o)) # print(m) # print(n) # print(n) # print(n1) # print(o) # print(o) # print(o) # print(p) # put your python code here # s= 0 # t = '' # t = 0 # w = list(map(int,input().split())) # w= 0 # while a != 0 or b != 0 or c != 0: # while count <= n: # while i < 1000: # while m > n: # x1 = int(input()) # x2 = int(input()) # y1 = int(input()) # y2 = int(input()) # l = [] # n = str(input()) # for i in n: # l.append(i) # if len(n) > 10: # print(l[0] + str(len(n)-2) + l[-1]) # else: # print(n) # l = [] # N = int(input()) # word_idx = 0 # for i in range(N): # word = str(input()) # if len(word) <= 10: # l.append(word) # else: # sym_list = list(word) # t = "".join( sym_list[:1] + [str(len(word) - 2)] + sym_list[-1:]) # l.append(t) # for i in l: # print(i) k=0 t = 0 n,m = map(int, input().split()) while n != 0: n-=1 t+=1 if t == m: n+=1 t = 0 k+=1 print(k)
7
PYTHON3
a,b = list(map(int,input().split())) total = a left = 0 while a > 0: total += a//b a = a%b+a//b if a//b == 0 : break print(total)
7
PYTHON3
a,b=map(int,input().split()) hours=a while a>=b: hours+=a//b a=a//b+a%b print(hours)
7
PYTHON3
def main(): a, b = [int(x) for x in input().split()] counter = a while a >= b: new_candles = a // b counter = counter + new_candles temp = a % b a = temp + new_candles print(counter) main()
7
PYTHON3
a, b = map(int, input().split()) answer = a while a >= b: answer += a // b a = a % b + a // b print(answer)
7
PYTHON3
inp = input() lt = inp.split(' ') nums = list(map(int, lt)) a = nums[0] b = nums[1] h = a while a >= b: g = a // b r = a % b h = h + g a = g + r print(h)
7
PYTHON3
a, b= map(int, input().split()) s, c= 0, 0 while a: s+= a c+= a%b a//= b if(not a and c>= b): a= c//b c%= b print(s)
7
PYTHON3
a, b = list(map(int, input().split())) result = 0 while a >= b: result += b a -= b a += 1 print(result+a)
7
PYTHON3
a,b=map(int,input().split()) t=a while(a>=b): t+=a//b a=a//b+a-a//b*b print(int(t))
7
PYTHON3
a, b = [int(x) for x in input().split()] used = 0 counter = 0 while a > 0 or used >= b: counter += 1 a -= 1 used += 1 if used > b: used -= b a += 1 print(counter)
7
PYTHON3
a,b=[int(x) for x in input().split()] res = 0 burnt = 0 while a>0: burnt+=a res+=a a=burnt//b burnt = burnt%b print(res)
7
PYTHON3
a,b=input().split() a=int(a) b=int(b) c=a while(a>=b): c+=int(a//b) a=int(a//b)+a%b print(c)
7
PYTHON3
a,b = input().split() a = int(a) b = int(b) add = a x=0 while(True): c = a%b a = a//b a = a+c add+=(a-c) if(a<b): print(add) break
7
PYTHON3
a, b = map(int, input().split()) c = 0 count = 0 while a > 0: count+=1 a -= 1 c += 1 if c//b == 1: a+=1 c=0 print(count)
7
PYTHON3
ab = [int(x) for x in input().split()] cura = ab[0] curb = 0 count = 0 while cura > 0: count += cura curb += cura cura = curb // ab[1] curb = curb % ab[1] print(count)
7
PYTHON3
a, b = [int(x) for x in input().split( )] count=a summing=0 while (a>=b): summing+=a//b a=a//b+a%b print (count+summing)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int count = a; int rest = 0; while (a >= b) { rest = a % b; a = (a / b); count += a; a += rest; } cout << count << endl; return 0; }
7
CPP
a,b = map(int,input().split()) ans = a while(a>=b): ans += int(a/b) c = a % b a = int(a/b)+c print(ans)
7
PYTHON3
a, b = map(int, input().split()) d = a t = 0 while a >= b: c = a // b e = a - b * c a = c + e t += e d += c print(d)
7
PYTHON3
m, s = map(int, input().split()) print((m-1)//(s-1)+m)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 0; int add = 0; for (int i = a; i > 0; i--) { ans++; add++; if (add == b) { i++; add = 0; } } cout << ans; }
7
CPP
a, b = map(int, input().split()) count = 0 i = 1 while i*b <= a: i += 1 a += 1 while a > 0: count += 1 a -= 1 print(count)
7
PYTHON3
a,b=[int(x) for x in input().split()] s=a t=a while t//b>0: s=s+t//b t=t//b+t%b print(s)
7
PYTHON3
a,b = [int(i) for i in input().split()] t = a while t//b>0: a += t//b t = t//b + t%b print(a)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int sum = 0, x = a, r = 0; while (x >= b) { sum = sum + x / b; x = x / b + x % b; } cout << sum + a; }
7
CPP
a, b = map(int, input().split()) i = 0 while a > 0: a -= 1 i += 1 a = i while a > 0 and a >= b: i = i + a // b a = a // b + a % b print(i)
7
PYTHON3
#include <bits/stdc++.h> int main() { int a, b, c = 0, ans = 0; scanf("%d%d", &a, &b); while (a) { ans += a; c += (a % b); a /= b; if (a == 0 && c >= b) a = (c / b), c = c % b; } printf("%d\n", ans); return 0; }
7
CPP
""""""""""""""""""""""""""""""""""""""""""""" | author: mr.math - Hakimov Rahimjon | | e-mail: [email protected] | """"""""""""""""""""""""""""""""""""""""""""" #inp = open("lepus.in", "r"); input = inp.readline; out = open("lepus.out", "w"); print = out.write TN = 1 # =========================================== def solution(): a, b = map(int, input().split()) cur_a = a cur_b = 0 ans = 0 while cur_a>=cur_b: ans += cur_a cur_b += cur_a cur_a = cur_b//b cur_b = cur_b%b ans += cur_a cur_b += cur_a cur_a = cur_b//b cur_b = cur_b%b print(ans+cur_a) # =========================================== while TN != 0: solution() TN -= 1 # =========================================== #inp.close() #out.close()
7
PYTHON3
# New_Year_Candles.py a,b = map(int,input().split()) hour,close = a,a while(int(close//b)!=0): hour = hour + int(close//b) close = int(close//b) + (close%b) print(hour)
7
PYTHON3
a,b = input().split(' ') a,b = int(a),int(b) c = 0 h = 0 while a > 0: h += a c += a a = int(c/b) c = c%b print(h)
7
PYTHON3
a,b = map(int,input().split()) output = a candles = a//b overflow = a%b while candles >= 1 or overflow >=b: if overflow >= b: overflow-=b candles+=1 output += candles a = candles candles = a//b overflow += a%b print(output)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, p, q, i, j, r, n; cin >> a >> b; p = a; while (a >= b) { q = a / b; p += q; r = a % b; a = q + r; } cout << p << endl; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int i, a, b, toth = 0, ca, cb; cin >> a >> b; toth += a; ca = a; cb = 0; while (1) { if (ca > 0) { cb += ca; ca = cb / b; toth += ca; cb = cb % b; } else { break; } } cout << toth; return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int start_up() { ios_base::sync_with_stdio(false); cin.tie(NULL); return 0; } int static r = start_up(); int main() { long long a, b; cin >> a >> b; long long sum = 0; sum = a; while (b <= a) { long long c = a / b; a = c + (a % b); sum = sum + c; } cout << sum; return 0; }
7
CPP
a, b = [int(i) for i in input().split()] sum = a while(1): c = int(a/b) a = c+int((a%b)) sum = sum +c if a<b: break print(sum)
7
PYTHON3
x1,x2 = map(int,input().split()) answer = x1 while x1 // x2 > 0: notlighted = x1 % x2 answer += x1//x2 x1 = x1//x2 + notlighted print(answer)
7
PYTHON3
str1=input() L=str1.split(' ') a=int(L[0]) b=int(L[1]) number=a while a>=b: number+=1 a-=b a+=1 print(number)
7
PYTHON3
a,b=map(int,input().split()) time=0 out=0 while a!=0: a-=1 time+=1 out+=1 if out==b: out=0 a+=1 print(time)
7
PYTHON3
a, b = input().split() a = int(a) b = int(b) sum = a while a // b != 0: sum = sum + (a // b) a = (a // b) + (a % b) print(sum)
7
PYTHON3