solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
#include <bits/stdc++.h>
int main() {
long n, k, x, a, y;
scanf("%ld %ld", &n, &k);
a = n;
x = n;
while (x >= k) {
y = x % k;
x = x / k;
a = a + x;
x = x + y;
}
printf("%ld\n", a);
return 0;
}
| 7 |
CPP
|
a,b=[int(x) for x in input().split()]
old=ans=0
while a:ans+=a;old+=a%b;a//=b;a+=old//b;old%=b;
print(ans)
| 7 |
PYTHON3
|
# n = int(input())
# a = [1]
# for i in range(n):
# print(*a)
# a = [1] + [a[j] + a[j + 1] for j in range(i)] + [1]
#a = 1
#n = int(input())
#for i in range(2, n):
# if n % i == 0:
# a = 0
# break
#if a == 0:
# print("I am way to dumb to get an answer correctly")
# print("NO")
#else:
# print("YES")
# print("I am way to dumb to get an answer correctly")
#a = [int (x) for x in input().split()]
#for i in range(len(a) - 1 , -1, -1):
# print(a[i], end = " ")
#a = [int (x) for x in input().split()]
#if len(a) % 2 == 0 :
# for i in range (len(a) // 2 -1, -1, -1):
# print(a[i], end = " ")
# for j in range (len(a)//2, len(a)):
# print(a[j], end = " ")
#else:
# for i in range (len(a) // 2, -1, -1):
# print(a[i], end = " ")
# for j in range (len(a)//2, len(a)):
# print(a[j], end = " ")
#b = []
#c = []
#a = [int (x) for x in input().split()]
#for i in range(len(a)):
# if i % 2 == 0:
# b.append (a[i])
# else:
# c.append (a[i])
#c.reverse()
#print(*b, end = " ")
#print(*c, end = " ")
#b = 1
#n = int(input())
#a = [int(x) for x in input().split()]
#for i in range(len(a)):
# if a[i] == n:
# b = 0
# break
#if b == 0:
# print( i + 1 , sep="\n")
#else:
# print(-1)
#left = 0
#k = int(input())
#a = [int(x) for x in input().split()]
#right = len(a)
#while right - left > 1:
# middle = (right + left) // 2
# if k < a[middle]:
# right = middle
# else:
# left = middle
#if a[left] == k:
# print(left + 1)
#else:
# print(-1)
#a = input()
#for i in range(0, len(a)):
# if (i + 1) % 3 != 0:
# print(a[i], end = " ")
#a = input()
#for i in range(0, len(a)):
# if (i + 1) % 3 == 0 or (i + 1) % 2 == 0:
# print(a[i], end = " ")
#print([int(elem) for i, elem in enumerate(input().split()) if i % 3 != 0])
#class Cat:
# def __init__(self, face, paws, whiskers, belly, what_they_like, pawsonality):
# self.face = face
# self.paws = paws
# self.whiskers = whiskers
# self.belly = belly
# self.what_they_like = what_they_like
# self.pawsonality = pawsonality
# def __str__(self):
# return "face: {}\npaws: {}".format( self.face, self.paws, self.whiskers, self.belly, self.what_they_like, self.pawsonality)
#Tyson = Cat(1, 4, 18, 3.5, ["water", "food", "ropes", "blankets"], "playful, stubborn, sleepy")
#print(Tyson)
#a = list(input())
#b = list(reversed(a))
#if a == b:
# print("YES")
#else:
# print("NO")
#meow
#countmeow = 0
#a = list(input())
#b = list(reversed(a))
#for i in range(len(a)):
# if a[i] != b[i]:
# countmeow = countmeow + 1
#if countmeow == 0 and len(a) % 2 != 0:
# print("YES")
#elif countmeow == 2:
# print("YES")
#else:
# print("NO")
#input()
#letmeowchange = 0
#num = input()
#a = dict()
#if len(num) > 26:
# print(-1)
#else:
# for letter in num:
# if letter in a:
# a[letter] += 1
# else:
# a[letter] = 1
# for letter in a:
# letmeowchange += a[letter]-1
# print(letmeowchange)
#print(round(sum([float(i) for i in input().split()]), 1))
#a = [int(i) for i in input().split()]
#b = [int(j) for j in input().split()]
#for i in zip(b, a):
# print(*i, end = " ")
#print([int(-i) if i%2==0 else int(i) for i in range(1,int(input()) + 1)])
#cb = input()
#bc = [int(i) for i in input().split()]
#a = {elem1: elem2 for elem1, elem2 in zip(cb, bc)}
#print(a)
#b = 0
#for i in range(10, 100):
# if i % 5 != 0 and i % 7 != 0:
# b = b + 1
#print(b)
#a = int(input())
#b = " that I hate"
#c = " that I love"
#print("I hate", end = "")
#for i in range(a - 1):
# if i % 2 == 0:
# print(c, end = "")
# else:
# print(b, end = "")
#print(" it")
#a = int(input())
#b = [int(input()) for i in range(a)]
#c = b[0]
#d = 0
#for i in b[1::]:
# if i != c:
# d = d + 1
# c = i
#print(d + 1)
#input()
#letmeowchange = 0
#num = input()
#a = dict()
#if len(num) > 26:
# print(-1)
#else:
# for letter in num:
# if letter in a:
# a[letter] += 1
# else:
# a[letter] = 1
# for letter in a:
# letmeowchange += a[letter]-1
# print(letmeowchange)
#from math import ceil
#a = int(input())
#b = [int(i) for i in input().split()]
#c = sum(b)
#
#d = {1:0, 2:0, 3:0, 4:0}
#total = 0
#r2 = 0
#for i in b:
# if i in d:
# d[i] += 1
# else:
# d[i] = 1
#total = total + d[4]
#total = total + d[3]
#total = total + (d[2] // 2)
#r2 = d[2] % 2
#if r2 != 0:
# d[1] = d[1] - 2
# total = total + 1
#if d[1] > d[3]:
# total += ceil((d[1] - d[3]) / 4)
#print(total)
#n = int(input())
#a = [int(i) for i in input().split()]
#print(*sorted(a))
#s = list(input())
#t = list(input())
#a = list(reversed(s))
#if t == a:
# print("YES")
#else:
# print("NO")
#a = input().split()
#b = 0
#c = 0
#d = dict()
#for letter in a:
# if letter in d:
# d[letter] += 1
# else:
# d[letter] = 1
#for value in d.values():
# if value % 2 != 0:
# c = c + 1
#if c > 1:
# print("NO")
#else:
# print("YES")
#n = input()
#a = [int(i) for i in n]
#b = 0
#for i in a:
# if i == 4 or i == 7:
# b = b + 1
#if b == 4 or b == 7:
# print("YES")
#else:
# print("NO")
#n = input()
#a = [int(i) for i in n]
#b = 0
#c = 0
#a = "abcdefgthijklmnopqrstuvwxyz"
#s = input()
#for i in s:
# if i in a:
# b = b + 1
# else:
#c = c + 1
#if b == c or b > c:
# print(s.lower())
#else:
# print(s.upper())
#b = 0
#k = int(input())
#l = int(input())
#m = int(input())
#n = int(input())
#d = int(input())
#for i in range(1, d + 1):
# if i % k == 0:
# b = b + 1
# elif i % l == 0:
# b = b + 1
# elif i % m == 0:
# b = b + 1
# elif i % n == 0:
# b = b + 1
#print(b)
#a = input().split("WUB")
#for i in a:
# if i != '':
# print(i , end = " ")
#n, m = [int(i) for i in input().split()]
#f = [int(i) for i in input().split()]
#a = sorted(f)
#A = 0
#B = 0
#answer = 999999999999999999
#c = 3
#for i in range (0, len(a) - n + 1):
# A = a[i]
# B = a[i + n - 1]
# if B - A < answer:
# answer = B - A
#print(answer)
#s = [int(i) for i in input().split()]
#s = set(s)
#print(4 - len(s))
#n = int(input())
#a = [int(i) for i in input().split()]
#b = -9999999999999999999999999999
#c = 9999999999999999999999999999
#d = 0
#f = 0
#naswer = 0
#index = 0
#for i in range(len(a)):
# if a[i] > b:
# d = i
# b = a[i]
# if a[i] <= c:
# f = i
# c = a[i]
#index = len(a) - 1
#naswer = naswer + (index - f)
#naswer = naswer + d
#if f < d:
# naswer = naswer - 1
#print(naswer)
#t = int(input())
#naswer = 0
#for i in range (t):
# n = int(input())
# naswer = n // 2
# print(naswer)
#n, k = [int(i) for i in input().split()]
#naswer = 0
#if k <= (n + (n % 2)) // 2:
# naswer = k * 2 - 1
#else:
# naswer = (k - (n + (n % 2)) // 2) * 2
#print(naswer)
#n = int(input())
#a = [int(i) for i in input().split()] + [9999999999]
#for i in range(n):
#d = 0
#n = int(input())
#p = [int(i) for i in input().split()]
#q = [int(i) for i in input().split()]
#a = []
#for i in range(1, len(p)):
# a.append(p[i])
#for j in range(1, len(q)):
# a.append(q[j])
#b = set(a)
#for i in range(1, n + 1):
# if i in b:
# d = d + 1
#if d == n:
# print("I become the guy.")
#else:
# print("Oh, my keyboard!")
#n = int(input())
#a = [i for i in input().lower()]
#b = set(a)
#if len(b)>=26:
# print("YES")
#else:
# print("NO")
#n = int(input())
#a = {"Icosahedron" : 20, "Dodecahedron" : 12, "Octahedron" : 8, "Cube" : 6, "Tetrahedron" : 4}
#b = 0
#for i in range(n):
# c = input()
# b = b + a[c]
#print(b)
#a = input()
#b = input()
#c = input()
#d = dict()
#e = dict()
#for i in a:
# if i in d:
# d[i] = d[i] + 1
# else:
# d[i] = 1
#for i in b:
# if i in d:
# d[i] = d[i] + 1
# else:
# d[i] = 1
#for i in c:
# if i in e:
# e[i] = e[i] + 1
# else:
# e[i] = 1
#if d == e:
# print("YES")
#else:
# print("NO")#
#n, m = [int(i) for i in input().split()]
#b = min(n, m)
#if b % 2 !=0:
# print("Akshat")
#else:
# print("Malvika")
#
#n, m = [int(i) for i in input().split()]
#ho = "#"
#hi = "."
#for i in range(1, n + 1):
# if i % 4 != 0 and i % 2 == 0:
# print(hi*(m-1) + ho)
# elif i % 4 == 0:
# print(ho + hi* (m - 1))
# else:
# print(ho * m)
#n, m = [int(i) for i in input().split()]
#a = [int(i) for i in input().split()]
#hosss = 1
#besss = 0
#for i in a:
# if (i >= hosss):
# besss = besss + (i - hosss)
# else:(
# besss = besss + (n - hosss + i)
# hosss = i
#print(besss)
#n = int(input())
#x = [int(i) for i in input().split()]
#q = int(input())
#x.sort()
#for i in range(q):
# k = int(input())
# l = -1
# r = n
# while (r - l > 1):
# middle = l + (r - l) // 2
# if x[middle] <= k:
# l = middle
# else:
# r = middle
# print( l + 1 )
#a, b = [int(i) for i in input().split()]
#c = min(a, b)
#d = max(a, b)
#e = d - c
#print(c, e//2)
#k, r = [int(i) for i in input().split()]
#for i in range(1, 11):
# if ((k * i) - r) % 10 == 0:
# print(i)
# break
# if (k * i) % 10 == 0:
# print(i)
# break
#n = int(input())
#a = [int(i) for i in input().split()]
#m = int(input())
#q = [int(i) for i in input().split()]
#b = [a[0]]
#for i in range(1, len(a)):
# b.append(a[i] + b [i - 1])
#for i in range(len(q)):
# l = -1
# r = len(a)
# while (r - l > 1):
# mid = (l + r) // 2
# if b[mid] < q[i]:
# l = mid
# else:
# r = mid
# print(r + 1)
#n, t = [int(i) for i in input().split()]
#a = [0] + [int(i) for i in input().split()]
#b = []
#naswer = 0
#noswer = 0
#nul = 0
#for i in a:
# nul = nul + i
# b.append(nul)
#for i in range(1, n + 1):
# l = i - 1
# r = n + 1
# while(r - l > 1):
# mid = (l + r) // 2
# noswer = b[mid] - b[i - 1]
# if (noswer) <= t:
# l = mid
# else:
# r = mid
# naswer = max(naswer, l - i + 1)
#print(naswer)
#n, m, a, b = [int (i) for i in input().split()]
#if m * a <= b:
# print(n * a)
#else:
# c = n % m
# if c == 0:
# print((n//m) * b)
# if c != 0:
# d = a * c
# if d > b:
# print(b + ((n//m) * b))
# else:
# print(d + ((n//m) * b))
a, b = [int (i) for i in input().split()]
naswer = 0
c = 0
while a > 0:
naswer = naswer + a
c = c + a
a = c // b
c = c % b
print(naswer)
| 7 |
PYTHON3
|
numbers = list(map(int,input().split()))
a = numbers[0]
b = numbers[1]
hours = a
rest = a
while (a != 0):
a = rest//b
hours += a
rest = a + rest%b
print(hours)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
tmp = 0
hours = 0
while (a >= 0):
if tmp >= b:
a += 1
a -= 1
hours += 1
tmp -= b
tmp += 1
else:
a -= 1
hours += 1
tmp += 1
print(hours-1)
| 7 |
PYTHON3
|
n,k=map(int,input().split())
c=0
c+=n
while(n>=k):
c+=n//k
n=n%k + n//k
print(c)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int a, b, kq, i;
int main() {
cin >> a >> b;
while (a) {
a--;
kq++;
i++;
if (i == b) {
a++;
i = 0;
}
}
cout << kq;
return 0;
}
| 7 |
CPP
|
a,b=map(int,input().split())
h=0
while a>0:
h=h+1
a=a-1
if h%b==0:
a=a+1
print(h)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
h=a
x=a//b
while x>0:
x=a//b
h+=x
a=a%b+x
print(h)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, hours = 0, mod = 0, i = 0;
cin >> a >> b;
while (a) {
hours += a;
mod += (a % b);
a = a / b;
++i;
if (a == 0) {
a = (mod / b);
mod = mod % b;
}
}
cout << hours;
}
| 7 |
CPP
|
s=input()
s=s.split()
a=int(s[0])
b=int(s[1])
rem=a
ans=a
while rem>0:
if rem<b:
break
ans+=rem//b
rem=rem//b+rem%b
print(ans)
| 7 |
PYTHON3
|
a,b = map(int, input().split())
count = 0
while a > 0:
a -= 1
count += 1
if count % b == 0:
a += 1
print(count)
| 7 |
PYTHON3
|
n, m = map(int, input().split())
days = 0
while n > 0:
n -= 1
days += 1
if days % m == 0:
n += 1
print(days)
| 7 |
PYTHON3
|
inputLine = input()
inputList = inputLine.split(" ")
candle = int(inputList[0])
reuse = int(inputList[1])
time = 0
consume = 0
while candle != 0:
candle -= 1
consume += 1
if consume // reuse == 1:
candle += 1
consume = 0
time += 1
print(time)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
remain = a
sum = a
while remain >= b:
temp = remain // b
sum = sum + temp
remain = remain - temp * b + temp
print(sum)
| 7 |
PYTHON3
|
import math
from collections import defaultdict, Counter, deque
INF = float('inf')
def gcd(a, b):
while b:
a, b = b, a%b
return a
def isPrime(n):
if (n <= 1):
return False
i = 2
while i ** 2 <= n:
if n % i == 0:
return False
i += 1
return True
def primeFactor(n):
if n % 2 == 0:
return 2
i = 3
while (i ** 2) <= n:
if n % i == 0:
return i
i += 1
return n
def vars():
return map(int, input().split())
def array():
return list(map(int, input().split()))
def main():
n, b = vars()
ans = 0
unused = 0
while n > 0:
ans += n
unused += n - ((n // b) * b)
# print(unused)
ans += (unused // b)
unused += (unused // b)
unused -= (unused // b) * b
n //= b
print(ans)
if __name__ == "__main__":
# t = int(input())
t = 1
for _ in range(t):
main()
| 7 |
PYTHON3
|
a, b = map(int, input().split())
c = k = 0
while a:
k += a
a, c = (a + c) // b, (a + c) % b
print(k)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
t=a
while a>=b:
t+=(a//b)
a=((a//b)+(a%b))
print(t)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, fol, rem = 0;
cin >> a >> b;
fol = a;
while (a >= b) {
fol = fol + (a / b);
a = (a / b) + (a % b);
}
cout << fol << endl;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
int main() {
int a, b, c, d, e, t = 0, r;
scanf("%d%d", &a, &b);
r = a;
while (a >= b) {
c = a / b;
r = r + c;
t = a % b;
c = c + t;
a = c;
}
printf("%d", r);
}
| 7 |
CPP
|
#n = int(input())
n, m = map(int, input().split())
#s = input()
#c = list(map(int, input().split()))
'''for i in range(n):
c = list(map(int, input().split()))'''
l = 0
while n >= m:
l += (n // m) * m
n = n // m + n % m
l += n
print(l)
| 7 |
PYTHON3
|
from collections import deque
from math import ceil,floor,sqrt,gcd
def ii(): return int(input())
def mi(): return map(int,input().split())
def li(): return list(mi())
def si():return input()
a,b=mi()
c=a//b
s=a
c=0
for i in range(1,a+1):
if(i%b==0):
c+=1
while(c):
s1=s
s+=c
c=0
for i in range(s1+1,s+1):
if(i%b==0):
c+=1
print(s)
| 7 |
PYTHON3
|
a,b=map(int,(input()).split())
temp: int=0
s=0
x=a
y=0
while a>=b:
temp=int(a/b)
s+=temp
y=a%b
a=temp+y
if a==0:
break
print(int(x+s))
1
| 7 |
PYTHON3
|
l=[int(x) for x in input().split()]
a=l[0]
b=l[1]
n=(a-b)//(b-1)+1
hour=a+n
print(hour)
| 7 |
PYTHON3
|
n, m = map(int, input().split())
count1 = count2 = 0
while n != 0:
n -= 1
count1 += 1
count2 += 1
if count2 == m:
n += 1
count2 = 0
print(count1)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
t = 0
c = 0
while a > 0:
c += 1
t += 1
a -= 1
if t == b:
a +=1
t = 0
print(c)
| 7 |
PYTHON3
|
from sys import stdin,stdout
from math import ceil,floor,sqrt
from collections import deque,Counter
inp = stdin.readline
out = stdout.write
a,b=map(int,inp().strip().split())
c=(a*b-1)//(b-1)
print(c)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
count = a
while a >= b:
count+=a//b
a = a//b + a%b
print(count)
| 7 |
PYTHON3
|
a , b = input().split()
a = int(a)
b = int(b)
rez = a
while a>0:
rez += int(a/b)
a = int(a/b) + a%b
if int(a/b)==0:
break
print(rez)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
h=a
while a//b>0:
h+=a//b
a-=a//b*(b-1)
print(h)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c = 0, k = 0;
cin >> a >> b;
while (a > 0) {
a--;
c++;
if (c == b) {
a++;
c = 0;
}
k++;
}
cout << k;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, day = 1;
cin >> n >> m;
while (true) {
if (n == 0) return cout << day - 1, 0;
n--;
if (day % m == 0) n++;
day++;
}
cout << day << endl;
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace ::std;
int main() {
int j = 1, n, m, o = 0;
cin >> n >> m;
cout << n + ((n - 1) / (m - 1));
}
| 7 |
CPP
|
var = input()
n, m = var.split()
n = int(n)
m = int(m)
old_m = m
while n >= m:
n += 1
m += old_m
print(n)
#bit.do/soft-dev-ub
#
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
while (cin >> a >> b) {
int left = a;
while (left / b) {
a += left / b;
left = left - left / b * b + left / b;
}
cout << a << endl;
}
return 0;
}
| 7 |
CPP
|
a,b=map(int,input().split())
c,p=0,0
while True:
if(a==0):
break
a-=1
c+=1
p+=1
#print(a,b,c)
if c==b:
c=0
a+=1
print(p)
| 7 |
PYTHON3
|
import sys
if False:
input = open('candles.txt', 'r')
else:
input = sys.stdin
nums = input.readline().split()
a = int(nums[0])
b = int(nums[1])
hours = a
while a >= b:
hours = hours + (a//b)
a = a//b + a%b
print (hours)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
q = 0
while a > 0:
a -= 1
q += 1
if q % b == 0:
a += 1
print(q)
| 7 |
PYTHON3
|
x = input()
a, b = int(x.split()[0]), int(x.split()[1])
total = a
s = a
div = a // b
mod = 0
while div > 0:
div = s // b
mod = s % b
total += div
s = div + mod
print(total)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
result = a
while True:
if a < b:
break
result += a//b
a = a//b + a%b
print(result)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
s=0
c=0
while a > 0:
a-=1
c+=1
if c >= b:
c-=b
a+=1
s+=1
print(s)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
num = a
while a>=b:
t = a//b
num += t
a -= t*b
a += t
print(num)
| 7 |
PYTHON3
|
a,b=[int(i) for i in input().split()]
r=a
while (a//b >0):
r=r+(a//b)
a=a%b+a//b;
print(r)
| 7 |
PYTHON3
|
'''
Auther: ghoshashis545 Ashis Ghosh
college: jalpaiguri Govt Enggineering College
Date:14/03/2020
'''
from math import ceil,sqrt,gcd,log,floor
from collections import deque
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())
def main():
#for _ in range(ii()):
a,b=mi()
ans=a
c1=1
while(1):
c=0
for i in range(c1,a+1):
if(i%b==0):
c+=1
if(c==0):
break
c1=a+1
a+=c
print(a)
if __name__ == "__main__":
main()
| 7 |
PYTHON3
|
n, m = map(int, input().strip().split(' '))
k = 0
day = 0
while n != 0:
n -= 1
k += 1
if k == m:
n += 1
k = 0
day += 1
print(day)
| 7 |
PYTHON3
|
import math
a,b=map(int,input().split())
count=a
left=0
while(a>0):
a+=left
count+=math.floor((a)/b)
left=(a)%b
a=math.floor(a/b)
check=math.floor((a+left)/b)
if(check<0):
a=0
print(int(count))
| 7 |
PYTHON3
|
a, b= map(int,input().split())
y=a//b
yy=a%b
s=a+y
if a<b:
print(a)
else:
while y/b>0:
yy=yy+y%b
y=y//b
s=s+y
if y+yy>=b :
y=y+yy
yy=0
else:
break
print(s)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int a, b;
cin >> a >> b;
int ans = 0, good = a, burnt = 0;
while (true) {
ans += good;
int p = burnt;
if (good + p < b) break;
burnt = (good + p) % b;
good = (good + p) / b;
}
cout << ans;
}
| 7 |
CPP
|
s=input()
a=int(s.split()[0])
b=int(s.split()[1])
x=0
result=a
while a>0:
x+=a%b
a//=b
result+=a
if a==0 and x>=b:
a=x
x=0
'''while x>0:
x//=b
result+=x'''
print(result)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
s=0
c=a
while(a>=b):
d=a//b
s=s+d
r=a%b
a=d+r
s=s+c
print(s)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
def solve(rem,grp):
if rem<grp:
return 0
candies = rem//grp
return candies + solve(rem//grp + rem%grp,grp)
ans = a + solve(a,b)
print(ans)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, sum = 0;
cin >> a >> b;
sum += a;
while (a > 0) {
sum += a / b;
a = a / b + a % b;
if (a < b) break;
}
cout << sum;
return 0;
}
| 7 |
CPP
|
a , b = [int(i) for i in input().split()]
c = a // b
d = a % b
while c != 0:
a += c
c1 = c + d
c = (c + d) // b
if c1 < b:
d = 0
else:
d = c1 % b
print(a)
| 7 |
PYTHON3
|
n,m=map(int,input().split())
x=n
while n>=m:
x+=n//m
n=n//m+n%m
print(x)
| 7 |
PYTHON3
|
from sys import stdin
# a number of candles
# b make a new candle
# t number of total candles
a, b = [int(c) for c in stdin.readline().split()]
burnt = 0
burnt_candle = 0
# c candles remaining
time = 0
def re(candle, burnt_candle):
global time
time = time + candle
burnt_candle = burnt_candle + candle
candle = burnt_candle//b
burnt_candle = burnt_candle - candle*b
if candle>0:
return re(candle, burnt_candle)
else:
return time
print(re(a,0))
| 7 |
PYTHON3
|
isDebug = False
a, b = input().split(' ')
a = int(a)
b = int(b)
print(f'a={a}, b={b}') if isDebug else ''
r = 0
u = 0
while True:
print(f'-----\na={a}') if isDebug else ''
r = r + a
if a+u < b:
break
u = u + a
a = int(u / b)
u = u % b
print(f'u={u}') if isDebug else ''
print(f'{r}')
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int a = 0, b = 0;
cin >> a >> b;
int count = 0;
count += a;
while (a >= b) {
int temp = a / b;
int rim = a % b;
count += temp;
a = temp + rim;
}
cout << count << endl;
return 0;
}
| 7 |
CPP
|
import sys
def solution(a,b):
total=0
kalan=0
while a>=1:
total+=a
kalan += a % b
a//=b
'print(kalan,"kalan")'
while (kalan>=b):
a+=1
kalan-=b
'print(a,"<<AAA")'
return total
def main():
n, m = map(int, sys.stdin.readline().strip().split(' '))
print(solution(n,m))
if __name__ == "__main__":
main()
| 7 |
PYTHON3
|
a,b = list(map(int, input().split()))
c=0
while a!=0:
c=c+1
if c%b==0:
a=a+1
a=a-1
print(c)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
hours = a
trash = 0
while a >= b:
hours += a//b
trash = a - (a//b)*b
a = a//b + trash
print(hours)
| 7 |
PYTHON3
|
lines = input()
lines = lines.split(" ")
a = int(lines[0])
b = int(lines[1])
hours = 0
def new_candles(n,b,hours):
undone_candles = n
while (n>=b):
full_candles = int(n/b)
undone_candles = int(n%b)
hours = hours + full_candles
n = full_candles + undone_candles
#print("n is {} full is {} undone is {} b is {}".format(n,full_candles,undone_candles,b))
return hours
hours = a + new_candles(a,b,hours)
print(int(hours))
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, count = 0;
cin >> a >> b;
count = a;
while (a - b >= 0) {
int x = a / b;
count += x;
a = x + a % b;
}
cout << count << endl;
}
| 7 |
CPP
|
c,b=map(int,input().split());print((c*b-1)//(b-1))
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int c, b, a, totc = 0;
cin >> c >> b;
a = c;
totc += c;
while (b <= a) {
totc += a / b;
a = (a / b) + (a % b);
}
cout << totc << endl;
return 0;
}
| 7 |
CPP
|
a, b = [int(x) for x in input().split()]
ans = 0
crash = 0
while a > 0:
ans += a
crash += a
a = 0
a = crash // b
crash -= a*b
print(ans)
| 7 |
PYTHON3
|
a,b=list(map(int,input().split()))
print((a-1)//(b-1)+a)
| 7 |
PYTHON3
|
a, b = input().split()
a = int(a)
b = int(b)
t=a
n=0 #chas
k=0
while a>0 :
a=a-1
n=n+1
k=k+1
if k%b==0:
a=a+1
print(n)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
s = a
r = 0
while a >= b:
r = r + a%b
s = s + a//b
a = a//b
if r >= b:
a = a + b
r = r - b
# print(s,r,a)
print(s+(r+a)//b)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
t=a
while True:
t+=a//b
a=a%b+a//b
if a<b:
break
print(t)
| 7 |
PYTHON3
|
n, m=map(int, input().split())
k=0
for i in range(2000):
if n>0:
k+=1
n-=1
if i%m==0:
n+=1
else:
print(k-1)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1000000;
int main() {
int a, b;
cin >> a >> b;
int rez = 0;
rez = a;
while (a >= b) {
int d = a / b;
rez += d;
a -= d * b;
a += d;
}
cout << rez << '\n';
return 0;
}
| 7 |
CPP
|
a, b = map(int, input().split(' '))
cou = a
while a >= b:
cou += a // b
a = a // b + a % b
print(cou)
| 7 |
PYTHON3
|
n,m = map(int,input().split())
k = n
p = n
if n < m:
print(k)
elif n == m:
print(k + 1)
else:
while p >= m:
k += p // m
p = p // m + p % m
print(k)
| 7 |
PYTHON3
|
a, b = map(int,input().split())
c = 0
m = 0
while a != 0:
c += a
m += a
a = m//b
m = m % b
print(c)
| 7 |
PYTHON3
|
a, b = input().split()
a = int(a)
b = int(b)
khela = a
while a >= b:
x = a%b
a = int(a / b)
khela += a
a += x
print(khela)
| 7 |
PYTHON3
|
l=list(map(int,input().strip().split()))
a=l[0]
b=l[1]
print(a+(a-1)//(b-1))
| 7 |
PYTHON3
|
a,b =[int(x) for x in input().split()]
printre = 0
c= 0
while a!=0:
printre +=a
c += a%b
a //= b
if c>= b:
a+=1
c-=b
print(printre)
| 7 |
PYTHON3
|
a, b = list(map(int, input().split()))
hours = 0
while a >= b:
hours += b
a = a - b + 1
hours += a
print(hours)
| 7 |
PYTHON3
|
# # start = []
# # maximum = 0
# # arr = input()
# # maxtotal = 0
# # hold = 0
# # mapping = {"[":"]", "(":")"}
# #
# # finishing = 0
# # once = 0
# # starting = 0
# # total = 0
# # flag =True
# # for i in range(len(arr)):
# # if arr[i] in ["(","["]:
# # if flag:
# # start.clear()
# # total = 0
# # hold = 0
# # flag = False
# # start.append(arr[i])
# #
# #
# #
# # else:
# # if start:
# # now = start.pop()
# # if mapping[now] != arr[i]:
# #
# # hold = 0
# # total = 0
# # start.clear()
# # else:
# #
# # if now == "[":
# # hold += 1
# # total += 1
# # if maximum < hold or (maximum == hold and total > hold):
# # maximum = hold
# # maxtotal = total
# # finishing = i
# # starting = finishing-(total*2-1)
# #
# #
# # else:
# # hold = 0
# # total = 0
# #
# # print(start, maximum, maxtotal,total, starting, finishing, i, arr[i], "--")
# #
# #
# #
# #
# #
# #
# # if (maximum < hold or (maximum == hold and total > hold)) and not start:
# # maximum = hold
# # finishing = i+1
# # maxtotal = total
# # starting = i - (maxtotal * 2 - 1)
# #
# # hold = 0
# #
# # print(starting, finishing)
# # print(maximum)
# #
# # print(arr[starting:finishing+1] if starting != finishing else "")
#
# #
# # mapping = {"[": "]", "(": ")"}
# # stack = []
# #
# # arr = input()
# #
# # everything = []
# #
# #
# # for i in range(len(arr)):
# #
# # if arr[i] in ["(", "["]:
# # stack.append([arr[i], i])
# #
# # else:
# # if stack:
# # now = stack.pop()
# # if mapping[now[0]] != arr[i]:
# #
# # stack.clear()
# #
# # else:
# # everything.append([now[1], i])
# #
# #
# #
# # print(everything)
# # prev = []
# # i = 0
# # while i < len(everything):
# # print(arr[max_end - (2 * ttl_max - 1):max_end + 1], everything[i], prev)
# # cur = prev if prev else everything[i]
# # try:
# # if cur[0] > everything[i+1][0] and cur[1] < everything[i+1][1]:
# # cur_ttl = everything[i+1][3]
# # cur_sqr = everything[i+1][2]
# # if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# # sq_max = cur_sqr
# # ttl_max = cur_ttl
# # max_end = everything[i+1][1]
# # prev = [everything[i+1][0],everything[i+1][1],cur_sqr,cur_ttl]
# # i+=1
# # elif cur[1]+1 == everything[i+1][0]:
# # cur_ttl = everything[i+1][3] + cur[3]
# # cur_sqr = everything[i+1][2] + cur[2]
# # if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# # sq_max = cur_sqr
# # ttl_max = cur_ttl
# # max_end = everything[i+1][1]
# # prev = [cur[0], everything[i + 1][1], cur_sqr, cur_ttl]
# # i+=1
# # else:
# # prev = []
# #
# # except:
# # pass
# # cur_ttl = cur[3]
# # cur_sqr = cur[2]
# # if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# # sq_max = cur_sqr
# # ttl_max = cur_ttl
# # max_end = cur[1]
# # i += 1
# #
# # print(sq_max)
# # print(arr[max_end - (2 * ttl_max - 1):max_end + 1])
#
#
# start = []
# maximum = 0
# arr = input()
# maxtotal = 0
# hold = 0
# mapping = {"[":"]", "(":")"}
#
# finishing = 0
# once = 0
# starting = 0
# total = 0
# flag =True
# everything = []
# for i in range(len(arr)):
# if arr[i] in ["(","["]:
# if flag:
# start.clear()
# total = 0
# hold = 0
# flag = False
# start.append(arr[i])
#
#
#
# else:
# if start:
# now = start.pop()
# if mapping[now] != arr[i]:
#
# flag = True
# hold = 0
# total = 0
# start.clear()
# else:
# flag = True
# if now == "[":
# hold += 1
# total += 1
# if total != 0:
# maximum = hold
# maxtotal = total
# finishing = i
# starting = finishing-(total*2-1)
# everything.append([starting, finishing, hold, total])
#
# else:
# hold = 0
# total = 0
#
#
#
#
#
#
#
#
# if (maximum < hold or (maximum == hold and total > hold)) and not start:
# maximum = hold
# finishing = i+1
# maxtotal = total
# starting = i - (maxtotal * 2 - 1)
# everything.append([starting, finishing, hold, total])
# hold = 0
#
# print(everything)
# print(maximum)
#
# print(arr[starting:finishing+1] if starting != finishing else "")
#
#
# ttl_max = 0
# sq_max = 0
# cur_sqr = 0
# cur_ttl = 0
# max_end = 0
# prev = []
# i = 0
# while i < len(everything):
# print(everything[i],"--")
# cur = prev if prev else everything[i]
# try:
# if cur[0] > everything[i+1][0] and cur[1] < everything[i+1][1]:
# cur_ttl = everything[i+1][3]
# cur_sqr = everything[i+1][2]
# if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# sq_max = cur_sqr
# ttl_max = cur_ttl
# max_end = everything[i+1][1]
# prev = [everything[i+1][0],everything[i+1][1],cur_sqr,cur_ttl]
# i+=1
# elif cur[1]+1 == everything[i+1][0]:
# cur_ttl = everything[i+1][3] + cur[3]
# cur_sqr = everything[i+1][2] + cur[2]
# if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# sq_max = cur_sqr
# ttl_max = cur_ttl
# max_end = everything[i+1][1]
# prev = [cur[0], everything[i + 1][1], cur_sqr, cur_ttl]
# i+=1
# else:
# prev = []
#
# except:
# pass
# cur_ttl = cur[3]
# cur_sqr = cur[2]
# if sq_max < cur_sqr or (sq_max == cur_sqr and ttl_max < cur_ttl):
# sq_max = cur_sqr
# ttl_max = cur_ttl
# max_end = cur[1]
# i += 1
# print(arr[max_end - (2 * ttl_max - 1):max_end + 1], prev)
# print(sq_max)
# print(arr[max_end - (2 * ttl_max - 1):max_end + 1])
a, b = list(map(int,input().split()))
total = 0
left = 0
while a > 0:
total += a
left += a % b
if left // b == 0:
a = a//b
else:
a = a//b+left//b
left = left%b
print(total)
| 7 |
PYTHON3
|
s = input()
a = s.split()
for i in range(len(a)):
a[i] = int(a[i])
i = a[0]
while a[1] <= a[0]:
i += int(a[0] / a[1])
n = a[0] % a[1]
m = int(a[0] / a[1])
a[0] = a[0]%a[1] + int(a[0]/a[1])
print(i)
| 7 |
PYTHON3
|
l=list(map(int,input().split()))
total=0
reminder=0
while(l[0]!=0):
total+=l[0]
reminder+=l[0]%l[1]
l[0]=l[0]//l[1]
while(reminder//l[1]!=0):
total+=reminder//l[1]
reminder=(reminder%l[1])+(reminder//l[1])
print(total)
| 7 |
PYTHON3
|
f = input().split()
a = int(f[0])
b = int(f[1])
candles = a
hours = 0
while candles > 0:
#burn candle
hours += 1
candles -= 1
if hours % b == 0:
candles += 1
print(hours)
| 7 |
PYTHON3
|
[a,b] = list(map(int,input().split()))
h = 0
c = a
des = 0
flag = True
while flag:
if des == b:
c += 1
des -= b
if c == 0:
flag = False
else:
c -= 1
h += 1
des += 1
print(h)
| 7 |
PYTHON3
|
candles = input().split(' ')
number_of_candles = int(candles[0])
number_for_refactoring = int(candles[1])
hours = 0
busted_candles = 0
while number_of_candles:
busted_candles += 1
hours += 1
number_of_candles -= 1
if busted_candles % number_for_refactoring == 0:
busted_candles -= number_for_refactoring
number_of_candles += 1
print(hours)
| 7 |
PYTHON3
|
line=input()
A,B=line.split()
a,b=int(A),int(B)
m=0
c=0
while a!=0:
m=m+a
c=c+a%b
a=a//b
if c>=b:
c=c-b
a=a+1
print(m)
| 7 |
PYTHON3
|
candle,b = map(int,input().split())
i=0
h=0
while candle>0:
candle-=1
i+=1
h+=1
if i==b:
candle+=1
i=0
print(h)
| 7 |
PYTHON3
|
a,b = [int(i) for i in input().split()]
count = 0
res = 0
while a > 0:
res+=1
a-=1
count+=1
if count == b:
a+=1
count=0
print(str(res))
| 7 |
PYTHON3
|
##############
# Problem set : Soluton_Hub Coding Facebook Begineer
################
# X is Orignal candle and If X burn it makes Y candels
X, Y = list(map(int, input().split()))
# all for total number that take that candles
newCandels = 0
# while loop is checking new candles is greater than original candels than stop making new candles
# X = 4 Y = 2
while (X >= Y):
# newCandel = 2 newCandel = 4 newCandle = six
# X = 2 , X = 3 X = 1 X = 2 X = 0 X = 1
newCandels += Y
X -= Y ## X = X - Y
X = X + 1
print(X + newCandels)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
z = a
while a >= 1:
a = a / b
z += a
print(int(z))
| 7 |
PYTHON3
|
import sys
from copy import copy
a, b = map(int, input().split())
t = 0
p = 0
while 1:
t += a
p += a
a = 0
if p // b == 0: break
a += p // b
p -= (p // b)*b
print(t)
| 7 |
PYTHON3
|
a, b = [int(x) for x in input().split()]
res = 0
while a >= b:
res += b
a -= b
a += 1
print(res + a)
| 7 |
PYTHON3
|
import sys
a, b = [int(el) for el in input().split()]
res = a
cond = True
while cond:
div, mod = divmod(a, b)
a = div + mod
res += div
cond = a >= b
print(res)
| 7 |
PYTHON3
|
a, b = list(map(int, input().split()))
print( ((a*b-1) // (b-1)) )
| 7 |
PYTHON3
|
n=input().split()
a=int(n[0])
b=int(n[1])
s=a
while a>=b:
n=divmod(a,b)
s+=n[0]
a=n[0]+n[1]
print(s)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << (a * b - 1) / (b - 1);
return 0;
}
| 7 |
CPP
|
import math
a,b = map(int,input().split())
candles = a
rem = 0
for i in range(math.floor(math.log(a,b))+1):
candles += a//b
a = a//b + a%b
print(candles)
| 7 |
PYTHON3
|
n, m = map(int, input().split())
ans = 0
while(n != 0):
n -= 1
ans += 1
if ans % m == 0:
n += 1
print(ans)
| 7 |
PYTHON3
|
import math
a, b = [int(x) for x in input().split()]
total = a
while a >= b:
total += math.floor(a/b)
a = math.floor(a/b) + a%b
print(total)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int a, b;
int s, k;
while (~scanf("%d%d", &a, &b)) {
int sum = 0;
sum += a;
s = a;
while (s >= b) {
k = s % b;
s = s / b;
sum = sum + s;
s = s + k;
}
printf("%d\n", sum);
}
return 0;
}
| 7 |
CPP
|
#-*- coding: utf-8 -*-
a, b = map(int, input().split())
n = 0
shorele = 0
while a > 0:
n += a
shorele += a
a = shorele // b
shorele = shorele % b
print(n)
| 7 |
PYTHON3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.