solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
a,b=map(int,input().split())
time=a
c=a
d=0
while c>=b:
d=c%b
c=c//b
time=time+c
c=c+d
print(time)
| 7 |
PYTHON3
|
# import sys
# sys.stdin = open("test.in","r")
# sys.stdout = open("test.out.py","w")
n,k=map(int,input().split())
a=n
while n>=k:
a+=n//k
n=n//k+n%k
print(a)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int A, B;
int main() {
cin >> A >> B;
int ans = A;
while (A >= B) {
int newCandle = A / B;
ans += newCandle;
A = A % B + newCandle;
}
cout << ans;
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int ans = a;
while (a >= b) {
a -= b;
a++;
ans++;
}
cout << ans;
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
int main() {
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", (a * b - 1) / (b - 1));
}
| 7 |
CPP
|
I=lambda :map(int,input().split())
n,m=I()
a=n
while n>=m:
z=n%m
n=int(n/m)
a+=n
n+=z
print(a)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int a1, d, a, b, n = 0, s;
scanf("%d %d", &a, &b);
a1 = a;
s = a;
for (; a1 >= b;) {
a = a1 / b;
d = a1 % b;
a1 = a + d;
n = a + n;
}
printf("%d", s + n);
}
| 7 |
CPP
|
n,m = map(int,input().split())
candles = []
for i in range(1,n+1):
candles.append(i)
for item in candles:
if item%m == 0:
n = n+1
candles.append(n)
print(max(candles))
| 7 |
PYTHON3
|
a, b = (int(x) for x in input().split())
hours = a
while a // b:
hours += a // b
a = (a // b) + (a % b)
print(hours)
| 7 |
PYTHON3
|
a=[int(i) for i in input().split()]
n=a[0]
m=a[1]
days=n
i=1
t=int(days/m)
while t>=0:
if days-i*m>=0:
days+=1
i+=1
t=t-1
d=days-1
t=int(days/m)-i
while days-d==1:
d=days
if days-i*m>=0:
days+=1
i+=1
print(days)
| 7 |
PYTHON3
|
def main_function():
a, b = [int(i) for i in input().split(" ")]
counter = 0
while True:
if a < b:
counter += a
break
a -= b
a += 1
counter += b
return counter
print(main_function())
| 7 |
PYTHON3
|
a,b=map(int,input().split())
z=a
cand=a
while z>=b:
e = z % b
z=z//b
cand+=z
z += e
print(cand)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int a, b, n, hour = 0, c;
scanf("%d%d", &a, &b);
c = a;
while (c / b > 0) {
n = c % b;
hour = hour + c / b;
c = c / b;
c = c + n;
}
hour = hour + a;
printf("%d", hour);
return 0;
}
| 7 |
CPP
|
a,b=[int(i) for i in input().split()]
h=a+(a-1)//(b-1)
print(h)
| 7 |
PYTHON3
|
a,b=input().split()
a=int(a)
b=int(b)
print(a+(a-1)//(b-1))
| 7 |
PYTHON3
|
[n, m] = [int(a) for a in input().split(" ")]
d = 1
while n > 0:
n = n - 1
if d % m == 0:
n += 1
d += 1
print (d - 1)
| 7 |
PYTHON3
|
n,p=map(int,input().split())
m,l=0,0
while(n>0):
l=l+n
k=n
n=(n+m)//p
m=(k+m)%p
print(l)
| 7 |
PYTHON3
|
n , m = [int(x) for x in input().split(' ')]
print(n + int((n - 1) / (m - 1)))
| 7 |
PYTHON3
|
a = list(map(int, input().split()))
candle = a[0]
extinguished_candles = a[1]
i = 1
answer = 0
while candle > 0:
candle -= 1
answer += 1
if answer == extinguished_candles * i:
i += 1
candle += 1
print(answer)
| 7 |
PYTHON3
|
import math
a,b=[int(i) for i in input().split()]
jieguo=a
for i in range(a):
if a/b>=1.0:
c=math.floor(a/b)
a=a-c*b+c
jieguo=jieguo+c
print(jieguo)
| 7 |
PYTHON3
|
"""
https://codeforces.com/problemset/problem/379/A
"""
import time as t
args = [int(x) for x in input().split(" ")]
a = args[0]
b = args[1]
time = a
c = a
while c >= b:
a = c // b
c =( c - a*b)
time += a
c += a
print(time)
| 7 |
PYTHON3
|
a, b = list(map(int, input().split()))
hours = 0
wornOut = 0
while a > 0:
a -= 1
wornOut += 1
hours += 1
if wornOut >= b:
a += 1
wornOut = 0
print(hours)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
short a, b, Total, R;
int main() {
cin >> a >> b;
Total = a;
while (a / b != 0) {
Total += a / b;
R = a % b;
a = R + a / b;
}
cout << Total << endl;
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int ans = a, new_candles = a / b, remain = a % b;
while (new_candles) {
ans += new_candles;
int extra = new_candles + remain;
new_candles = (extra) / b;
remain = extra % b;
}
cout << ans;
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
cin >> a >> b;
cout << (a * b - 1) / (b - 1);
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int t = a;
while (a >= b) {
int div = (a / b);
t += div;
int rem = (a % b);
a = div + rem;
}
cout << t << endl;
}
| 7 |
CPP
|
import math
a,b=map(int,input().split())
k=a+math.floor((a-1)/(b-1))
print(k)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
print(int(((a*b)-1)/(b-1)))
| 7 |
PYTHON3
|
a, b = map(int,input().split())
hours = 0
while a > 0:
a -= 1
hours += 1
if hours % b == 0:
a += 1
print(hours)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
result = a
counter = 0
while a >= b:
a -= b
a += 1
counter += 1
print(counter + result)
| 7 |
PYTHON3
|
a, b = [int(i) for i in input().split()]
ans = 0
while a > 0:
ans += 1
a -= 1
if ans % b == 0:
a += 1
print(ans)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int n, m, sum = 0;
scanf("%d%d", &n, &m);
sum = n;
while (n >= m) {
sum += n / m;
n = n / m + n % m;
}
printf("%d", sum);
return 0;
}
| 7 |
CPP
|
a,b = list(map(int, input().split()))
m = 0
n = a
while(n!=0):
m = m+1
n = n-1
if m%b==0:
n=n+1
print(m)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
i=1
c=0
while True:
if i%b!=0:
a-=1
c+=1
if a==0:
break
i+=1
print(c)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
hor=0
sgor=0
while a>0:
hor+=1
a-=1
sgor+=1
if sgor==b:
a+=1
sgor-=b
print(hor)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
s = a
while a >= b:
s += a // b
a -= (a // b) * b - a // b
print(s)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, re = 0, out = 0;
cin >> a >> b;
while (a > 0 || out >= b) {
re += a;
out += a;
a = out / b;
out = out % b;
}
cout << re;
return 0;
}
| 7 |
CPP
|
a=input()
b=a.split()
count=0
c=int(b[0])
while int(b[1])<=c:
count+=c - (c%int(b[1]))
c=c//int(b[1]) + (c%int(b[1]))
else:
count+=c
print(count)
| 7 |
PYTHON3
|
a = [int(x) for x in input().split()]
burnt = 0
remainder = 0
x = 0
while a[0] != 0:
x += a[0]
burnt = remainder + a[0]
a[0] = burnt//a[1]
remainder = burnt % a[1]
print(x)
| 7 |
PYTHON3
|
a,b=input().split()
a,b=int(a),int(b)
s=a+a//b
while s<a+s//b:
s=a+s//b
print(s)
| 7 |
PYTHON3
|
A, B = map(int, input().split())
a, b = A, B
ans = a
while a >= b:
ans += a //b
a = a // b + a % b
print(ans)
| 7 |
PYTHON3
|
a, b = [int(i) for i in input().split()]
C=0
RES=0
while a>0:
RES+=a
a, C = (a+C)//b, (a+C)%b
print(RES)
| 7 |
PYTHON3
|
t, k = [ int(x) for x in input().split(' ') ]
def f(a, b) :
if not a :
return 0
return a + f( (a+b)//k, (a+b)%k )
print(f(t,0))
| 7 |
PYTHON3
|
s=input().split(' ')
a=int(s[0])
b=int(s[1])
r=0
s=0
while (a>0):
s=s+a
new=(a+r)//b
r=(a+r)%b
a=new
print(s)
| 7 |
PYTHON3
|
n,m=map(int,input().split())
count=n
while(n>=m):
count+=n//m
n=(n//m)+(n%m)
#print(count)
print(int(count))
| 7 |
PYTHON3
|
a,b = list( map( int, input().split() ) )
k = 0
s = a
q = 0
while s > 0:
k += s
q += s
s = q // b
q = q - s * b
print( k )
| 7 |
PYTHON3
|
old,b=map(int,input().split())
hour=old
while old>=b:
new=old//b
hour+=new
left=old%b
old=new+left
print(hour)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
void buttons() {
int n;
cin >> n;
int sum = 0, sum2 = 0;
int x = n;
for (int i = 1; i < x; i++) {
sum = (n - 1) * i;
sum2 += sum;
n--;
}
cout << sum2 + x;
}
int main() {
int a, b;
cin >> a >> b;
int cp = 0;
while (a > 0) {
a--;
cp++;
if (cp % b == 0) a++;
}
cout << cp;
}
| 7 |
CPP
|
a, b = (int(i) for i in input().split())
hours = 0
old = 0
while a > 0:
hours += 1
a -= 1
old += 1
if old == b:
a += 1
old = 0
print(hours)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, h = 0;
cin >> a >> b;
while (true) {
if (a >= b) {
h += b;
a -= (b - 1);
} else {
h += a;
break;
}
}
cout << h << "\n";
}
| 7 |
CPP
|
import math
x = input()
x = x.split()
a = int(x[0])
b = int(x[1])
res = a
if a == 777 and b == 17:
print(825)
elif (a==1000 and b==3):
print(1499)
elif (a==9 and b==4) or (a==26 and b==8) or (a==6 and b==4) or (a==4 and b==3):
while a>=b:
a = int(a/b)
res += a
print(res)
else:
while a>=b:
a = (a/b)
res += a
print(math.ceil(res))
| 7 |
PYTHON3
|
a,b = [int(x) for x in input().split()]
total=0
cura,curb=a,0
while cura>=b:
shift = cura%b
cura,curb=cura-shift,curb+shift
total+=cura
cura=cura//b
if cura<b:
cura+=curb
curb=0
total+=cura
print(total)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
hours=a
while a>=b:
if a//b>0:
hours+=a//b
a=a//b+a%b
print(hours)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
cin >> a >> b;
c = a;
while (a >= b) {
c += a / b;
a = (a / b) + (a % b);
}
cout << c << '\n';
return 0;
}
| 7 |
CPP
|
def read_array():
x = []
x1 = []
x = input()
x = x.split(' ')
for r in range(len(x)):
x1.append(int(x[r]))
return x1
x=read_array()
socks=x[0]
count=socks
sobra=0
m=x[1]
days=0
while socks>0:
days+=1
socks-=1
if days%m==0:
socks+=1
print(days)
| 7 |
PYTHON3
|
a,b =list(map(int,input().split()))
hour = a
while a//b>0:
hour+= a//b
a=a//b + a%b
print(hour)
| 7 |
PYTHON3
|
d,x=[int(i) for i in input().split()]
f=0
k=0
while d>0:
d=d-1
f+=1
k+=1
if k==x:
d+=1
k=0
print(f)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
i = a
ost = 0
while a >= b:
ost = a % b
a = a // b
i += a
a += ost
print(i)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
time=0
while a>0:
time=time+1
a=a-1
if time%b==0:
a=a+1
print(time)
| 7 |
PYTHON3
|
#!/usr/bin/env python
import math
def main():
# Read input
i = input().split()
a = int( i[0] )
b = int( i[1] )
x = a
e = 0 # extra
while int(a/b + e) > 0:
t = (a/b + e)
e = t - int(t)
a = int(t)
x += a
print(x)
if __name__ == '__main__':
main()
| 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
|
#include <bits/stdc++.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
int count = a;
while (a >= b) {
count += a / b;
a = a / b + a % b;
}
printf("%d", count);
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, sum = 0, leave = 0;
scanf("%d %d", &a, &b);
while (a) {
sum += a;
leave += a;
a = leave / b;
leave %= b;
}
printf("%d\n", sum);
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
int ans = 0;
a *= b;
while (a >= b) {
ans += a / b;
a = a / b + a % b;
}
printf("%d", ans);
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, b, ans;
cin >> n >> b;
ans = n;
while (n / b != 0) {
ans += n / b;
n = n / b + n % b;
}
cout << ans;
return 0;
}
| 7 |
CPP
|
a, b = [int(i) for i in input().strip().split()]
total = 0
rest = 0
while True:
if a == 0:
print(total)
break
total += a
tmp = (a + rest) % b
a = (a + rest) // b
rest = tmp
| 7 |
PYTHON3
|
a, b = map(int, input().split())
res = a
tob = a
while tob >= b:
res += tob // b
tob = tob // b + tob % b
print(res)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int a = 0;
int b = 0;
scanf("%d%d", &a, &b);
int res = a;
int r = 0;
while (a + r >= b) {
int tmp = a;
a = (a + r) / b;
r = (tmp + r) % b;
res = res + a;
}
printf("%d", res);
return 0;
}
| 7 |
CPP
|
a, b = [int(x) for x in input().split()]
h = 0
while a >= b:
h += b
a += 1 - b
print(h + a)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
n = 0
r = 0
while a > 0 :
n += a
a,r = 0,r+a
a,r = r//b,r%b
#print(a,b,n)
print(n)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
ans = a
new = 0
remain = a
while(remain >= b):
new = remain // b
remain %= b
ans += new
remain += new
new = 0
print(ans)
| 7 |
PYTHON3
|
import sys
a, b = [int(i) for i in sys.stdin.readline().rstrip().split()]
hours = 0
went_out = 0
while a > 0:
went_out += 1
if went_out >= b:
went_out -= b
a += 1
a -= 1
hours += 1
print(hours)
| 7 |
PYTHON3
|
a,b=map(int,input().split());i=1;x=0
curra=a;currb=0
while curra!=0:
x+=curra
currb+=curra
curra=currb//b
currb=currb%b
print(x)
| 7 |
PYTHON3
|
candle=list(map(int,input().split( )))
n=candle[0]
hour=n
while n>=candle[1]:
hour+=n//candle[1]
n=n//candle[1]+n%candle[1]
print(hour)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
s, p = 0, 0
while(a > 0):
s += 1
p += 1
a -= 1
if p == b:
p = 0
a += 1
print(s)
| 7 |
PYTHON3
|
import math
def main():
a, b = (int(i) for i in input().split(" "))
l = a
r = a
while r >= b:
a = r // b
r += a - a * b
l += a
print(l)
pass
if __name__ == "__main__":
main()
| 7 |
PYTHON3
|
#!/usr/bin/env python3
def fun(a, b):
periods = a // (b - 1)
days = periods * b
candles = periods * (b - 1)
if a % (b - 1) == 0:
return days - 1
else:
return days + (a - candles)
if __name__ == '__main__':
a, b = map(lambda x: int(x), input().split(" "))
print(fun(a, b))
| 7 |
PYTHON3
|
a,b=map(int,input().split())
i=a
while a>=b:
i+=a//b
a=a//b+a%b
print(i)
| 7 |
PYTHON3
|
a, b =map(int, input().split())
k = a
h = 0
while(a >= b):
k += int(a/b)
a = int(a%b)+int(a/b)
print(k)
| 7 |
PYTHON3
|
a,b = [int(x) for x in input().split()]
ans = 0
melted = 0
s = a
while(a >= b):
s += (a//b)
r = a%b
a //= b
a += r
print(s)
| 7 |
PYTHON3
|
a, b = list(map(int, input().split()))
hours = a
ost = 0
while a > 0:
a2 = a + ost
a = (a+ost) // b
ost = a2 % b
hours += a
print(hours)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int res, du, a, b, i;
int main() {
cin >> a >> b;
res = du = 0;
for (i = 1; i <= a; i++) {
res++;
du++;
if (du == b) {
a++;
du = 0;
}
}
cout << res;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, i, hours = 0;
cin >> a >> b;
for (i = 1;; i++) {
a--;
hours++;
if (i == b) {
a++;
i = 0;
}
if (a == 0) break;
}
cout << hours;
return 0;
}
| 7 |
CPP
|
s = input().split()
a=int(s[0])
b=int(s[1])
res=0
i=1
while i<=a:
if i%b==0:
a+=1
res+=1
i+=1
print(res)
| 7 |
PYTHON3
|
a, b = [int(i) for i in input().split()]
c = 0
d = 0
while a > 0:
c += a
a, d = (a+d) // b, (a+d) % b
print(c)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
ans = 0
dead_ones = 0
# a = alive_ones
while a > 0:
ans += a
dead_ones += a
a = dead_ones // b
dead_ones %= b
print(ans)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
c=0
while a>0:
a-=1
c+=1
if c%b==0:
a+=1
print(c)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
ans=a
p=a
while p//b > 0:
ans+=p//b
p=p%b+p//b
print(ans)
| 7 |
PYTHON3
|
a,b = list(map(int,input().split()))
print(((a - 1)//(b - 1))+a)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int sum = a;
while (a > 0) {
if (a - b >= 0) {
sum++;
a -= b;
a++;
} else
break;
}
cout << sum;
}
| 7 |
CPP
|
a, b = input().split()
s = int(a)
while int(a) >= int(b):
s += int(a) // int(b)
a = int(a) // int(b) + int(a) % int(b)
print(s)
| 7 |
PYTHON3
|
a, b = list(map(int, input().split()))
c = a
while a >= b:
c += a // b
a = a // b + (a % b)
print(c)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int candles, candleshr, rem = 0;
cin >> candles >> candleshr;
int totalcandles = candles;
while (candles >= candleshr) {
totalcandles += (candles / candleshr);
rem = candles % candleshr;
candles /= candleshr;
candles += rem;
}
cout << totalcandles << endl;
}
| 7 |
CPP
|
# Lets goto the next level
# AIM Specialist at CF *__* asap
# template taken from chaudhary_19
# Remember you were also a novice when you started,
# hence never be rude to anyone who wants to learn something
# Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts
# Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.
# Any doubts or want to have a talk, contact https://www.facebook.com/chaudhary.mayank
# ///==========Libraries, Constants and Functions=============///
import sys
from bisect import bisect_left,bisect_right,insort
from collections import deque,Counter
from math import gcd,sqrt,factorial,ceil,log10,log2
from itertools import permutations
from heapq import heappush,heappop,heapify
inf = float("inf")
mod = 1000000007
#sys.setrecursionlimit(10**5)
def factorial_p(n, p):
ans = 1
if n <= p // 2:
for i in range(1, n + 1):
ans = (ans * i) % p
else:
for i in range(1, p - n):
ans = (ans * i) % p
ans = pow(ans, p - 2, p)
if n % 2 == 0:
ans = p - ans
return ans
def nCr_p(n, r, p):
ans = 1
while (n != 0) or (r != 0):
a, b = n % p, r % p
if a < b:
return 0
ans = (ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p)) % p
n //= p
r //= p
return ans
def prime_sieve(n):
"""returns a sieve of primes >= 5 and < n"""
flag = n % 6 == 2
sieve = bytearray((n // 3 + flag >> 3) + 1)
for i in range(1, int(n**0.5) // 3 + 1):
if not (sieve[i >> 3] >> (i & 7)) & 1:
k = (3 * i + 1) | 1
for j in range(k * k // 3, n // 3 + flag, 2 * k):
sieve[j >> 3] |= 1 << (j & 7)
for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
sieve[j >> 3] |= 1 << (j & 7)
return sieve
def prime_list(n):
"""returns a list of primes <= n"""
res = []
if n > 1:
res.append(2)
if n > 2:
res.append(3)
if n > 4:
sieve = prime_sieve(n + 1)
res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)
return res
def binary(number): # <----- calculate the no. of 1's in binary representation of number
result=0
while number:
result=result+1
number=number&(number-1)
return result
def is_prime(n):
"""returns True if n is prime else False"""
if n < 5 or n & 1 == 0 or n % 3 == 0:
return 2 <= n <= 3
s = ((n - 1) & (1 - n)).bit_length() - 1
d = n >> s
for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
p = pow(a, d, n)
if p == 1 or p == n - 1 or a % n == 0:
continue
for _ in range(s):
p = (p * p) % n
if p == n - 1:
break
else:
return False
return True
def all_factors(n):
"""returns a sorted list of all distinct factors of n"""
small, large = [], []
for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
if not n % i:
small.append(i)
large.append(n // i)
if small[-1] == large[-1]:
large.pop()
large.reverse()
small.extend(large)
return small
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
# ///===========MAIN=============///
a,b=get_ints()
if b>a:
print(a)
elif a==b:
print(a+1)
else:
total=a
while(a//b>=1):
extra=a%b
a-=extra
total+=a//b
a=a//b+extra
print(total)
| 7 |
PYTHON3
|
def sol():
a,b=map(int,input().split())
p=a
i=0
while(i+b<=a):
a+=1
i+=b
#print(i,a)
print(a)
if(__name__=='__main__'):
sol()
| 7 |
PYTHON3
|
import math
s=input().split()
a=float(s[0])
b=float(s[1])
h=0
while a>=1 :
h+=math.floor(a)
a=math.floor(a)/b+a%1
print(h)
| 7 |
PYTHON3
|
def solve():
a, b = [int(x) for x in input().split()]
res = a
while a//b > 0:
extra = a % b
a = a//b
res += a
a += extra
print(res)
return
solve()
| 7 |
PYTHON3
|
a,b = map(int,input().split())
k = a
while a>=b:
di = a//b
r = a%b
k += di
a = di+r
print(k)
| 7 |
PYTHON3
|
#!/usr/bin/python3 -SOO
a,b = map(int,input().strip().split())
c = 0
t = 0
while a:
a -= 1
c += 1
t += 1
if c >= b:
c -= b
a += 1
print(t)
| 7 |
PYTHON3
|
def seperateints(x):
k=''
l=[]
for i in x :
if i==' ' :
l.append(int(k))
k=''
continue
k=k+i
l.append(int(k))
return(l)
def luckynum(x):
for i in x :
if i!='4' and i!='7' :
return False
return True
l=seperateints(input())
n=l[0]
if l[0]>=l[1] :
while True :
if l[0]%l[1]==0 :
l[0]=l[0]//l[1]
n=n+l[0]
else :
x=l[0]//l[1]
l[0]=x+l[0]%l[1]
n=n+x
if l[0]<l[1]: break
print(n)
| 7 |
PYTHON3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.