solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
n,m=map(int,input().split())
x=0
if m<=n:
x=n+((n-m)/(m-1))+1
print(int(x))
else:
x=n
print(x)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
k=a
ost=0
while a>=b:
ost=a%b
a=a//b
k=k+a
a=a+ost
print(k)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
ans = 0
while a>=b :
a-=b
a+=1
ans+=b
print(ans+a)
| 7 |
PYTHON3
|
n,t = list(map(int,input().split(" ")))
i=n
while n >= t:
i+=(n//t)
n=(n//t)+(n%t)
print(i)
| 7 |
PYTHON3
|
#a, b = [int(x) for x in input().split()]
#total = ends = 0
#remain = a
#while remain > 0:
# total += remain
# ends += remain%b
# remain = (remain-ends)//b
#print(total)
a, b = [int(x) for x in input().split()]
remain = a;total = ends = 0
while remain > 0:
total += remain
ends += remain
remain = ends//b
ends = ends%b
print(total)
| 7 |
PYTHON3
|
n = [int(x) for x in input().split(' ')]
count = n[0]
remain = 0
t = 0
while t == 0:
remain = n[0]%n[1]
n[0] = n[0]//n[1]
if n[0] >= 1:
count += n[0]
n[0] += remain
else:
break
print(int(count))
| 7 |
PYTHON3
|
a=input()
b=a.split()
for i in range(len(b)):
b[i]=int(b[i])
d=b[0]
f=b[1]
while b[0]>=b[1]:
e=b[0]//b[1]
f=b[0]%b[1]
b[0]=e+f
d+=e
print(d)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, hrs = 0;
cin >> a >> b;
while (a > 0) {
if (a - b >= 0) {
hrs = b + hrs;
a = a - b;
a = a + 1;
} else {
hrs = hrs + a;
a = a - a;
}
}
cout << hrs;
return 0;
}
| 7 |
CPP
|
a = list(map(int, input().strip().split()))
t = a[0]
w = a[1]
ans = t
while (t>=w):
ans+=(t//w)
t = (t//w) + (t % w)
print(ans)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
print(((a*b)-1)//(b-1))
| 7 |
PYTHON3
|
full, n = [int(i) for i in input().split()]
half = 0
hours =0
while full > 0:
hours = hours + full
half = half + full
full = half//n
half = half - (half//n)*n
print(hours)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
cur_b = 0
counter = 0
while a > 0:
counter += a
cur_b += a
a, cur_b = cur_b // b, cur_b % b
print(counter)
| 7 |
PYTHON3
|
'''
Created on Apr 21, 2016
Gmail : [email protected]
@author: Md. Rezwanul Haque
'''
a ,b = map(int,input().split())
res = (a*b-1)//(b-1)
print(res)
| 7 |
PYTHON3
|
a,b = map(int,input().strip().split())
result = a
remain = 0
while a>=b:
remain = a % b
result += a//b
a = a//b + remain
print(result)
| 7 |
PYTHON3
|
s = input()
l = s.split()
n = int(l[0])
m = int(l[1])
a = n
while n // m != 0:
k = n-(m*(n//m))
n = n//m
a += n
n += k
print(a)
| 7 |
PYTHON3
|
#n, k = map(int, input().split(" ")) # read multiple integers into different variables
#L = [int(x) for x in input().split()] # read multiple integers into a list
#print(' '.join(map(str, L))) # print multiple integers in one line
a, b = map(int, input().split(" ")) # read multiple integers into different variables
s = 0
burnt = 0
while (a > 0) :
s += a
burnt += a
a = burnt // b
burnt %= b
print(s)
| 7 |
PYTHON3
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 8 11:30:18 2019
@author: xungao
"""
a,b =(map(int, input().split()))
rest = a
num = a
while(rest>=b):
num += rest//b
rest = rest//b+rest%b
print(num)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
res=a
while a>=b:
a-=b-1
res+=1
print(res)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
sum,ost = 0,0
while a :
sum+=a
ost+=a%b
a//=b
a+=ost//b
ost%=b
print (sum)
| 7 |
PYTHON3
|
a, b = input().split()
tunde = 0
jaak = 0
terveid = int(a)
while True:
tunde += terveid
poolikuid = terveid + jaak
terveid = poolikuid // int(b)
jaak = poolikuid % int(b)
if terveid == 0:
break
print(tunde)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int a, b, c, d, sum = 0;
scanf("%d%d", &a, &b);
sum += a;
while (a >= b) {
sum = sum + a / b;
c = a / b;
d = a % b;
a = c + d;
}
printf("%d", sum);
return 0;
}
| 7 |
CPP
|
s=input()
n=[int(i) for i in s.split()]
a=n[0]
b=n[1]
tnoc=a
tnoc+=int(a/b)
a=int(a/b)+int(a%b)
while a>=b:
tnoc+=int(a/b)
a=int(a/b)+int(a%b)
print(tnoc)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
i = 0
while a > 0:
i += 1
a -= 1
a = i
while a > 0 and a >= b:
i = i + a // b
a = a // b + a % b
print(i)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
ans = 0
star = a
while a > 0:
ans += a
a = star // b
star = star % b
star = star + a
print(ans)
| 7 |
PYTHON3
|
n,l = [int(i) for i in input().split()]
counter = n
rem = n//l
while(rem>0):
counter+=rem
n = n%l + n//l
rem = n//l
print(counter)
| 7 |
PYTHON3
|
import math
a, b = list(map(int, input().split()))
hrs = a
while a >= b:
a = a/b
#print(a)
hrs += a
#print((a/b)+hrs)
#print(round(hrs))
if (a/b)+hrs >= math.floor(hrs)+1:
print (math.floor((a/b)+hrs))
else:
print(math.floor(hrs))
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int64_t a, b, result = 0, wasted = 0;
cin >> a >> b;
cout << a + ((a - 1) / (b - 1)) << '\n';
return 0;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, sum = 0, m, r, k;
cin >> a >> b;
k = a;
while (a >= b) {
m = a / b;
r = a % b;
a = r + m;
sum = sum + m;
}
cout << k + sum << endl;
return 0;
}
| 7 |
CPP
|
a, b = map(int, input().split())
n1=((a*b-1)/(b-1))
n1 = int(n1)
print(n1)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
x=a
while True:
d=x//b
z=x%b
a+=d
x=d+z
if d==0:
break
print(a)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
n=a
r=0
while a>=(b-r):
a=(a+r)/b
n=n+int(a)
r=(n-int(a))%b
print(n)
| 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
|
a,b = map(int,input().split())
sums = a
while a >= b:
div = a//b
sums = sums + div
k = a%b
a = div + k
print(sums)
| 7 |
PYTHON3
|
a,b=input().split()
x=int(a)
a1=int(a)
b1=int(b)
while(a1>=b1):
x=x+(a1//b1)
a1=(a1//b1)+(a1%b1)
print(x)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, cnt = 0, nn = 0;
scanf("%d%d", &n, &m);
while (n) {
cnt++;
n--;
nn++;
n += nn / m;
nn %= m;
}
printf("%d\n", cnt);
}
| 7 |
CPP
|
# http://codeforces.com/problemset/problem/379/A
a, b = tuple(map(int, input().split()))
res = a
while True:
t = int(a/b)
r = a%b
res += t
a = t + r
if a<b:
break
print(res)
| 7 |
PYTHON3
|
a , b = [int(x) for x in input().split()]
count = a
while(a >= b):
count += int(a / b)
a = int(a / b) + int(a % b)
print(count)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, b, a, s, d, sum = 0;
cin >> n >> b;
s = n;
while (n >= b) {
sum = sum + n / b;
d = n % b;
a = n / b;
n = a + d;
}
cout << s + sum;
}
| 7 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
long long n, m, i, a, b, x, y;
int main() {
cin >> a >> b;
while (a > 0) {
a--;
x++;
if (x % b == 0) a++;
}
cout << x;
}
| 7 |
CPP
|
a, b = map(int, input().split())
hour = a
k = 0
c = 0
d = 0
e = 0
while a > 0:
d = a
e = b
c = d % e
k = a // b
a = c + k
hour = hour + k
if k == 0:
break
print(hour)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
count = a
while count >= 0:
count += a // b
if a//b == 0:
print(count)
break
a = a // b + a % b
| 7 |
PYTHON3
|
a,b=map(int,input().split())
ans=0
a1=a
r=0
while a1!=0:
ans+=a1
a1=(a+r)//b
r=a+r-a1*b
a=a1
print(ans)
| 7 |
PYTHON3
|
#in the nmae of god
#Mr_Rubik
n,k=map(int,input().split())
sum=n
while (n>=k):
sum+=n//k
n=n//k+n%k
print(int(sum))
| 7 |
PYTHON3
|
def main():
a, b = [int(v) for v in input().split()]
s = a
d = a
while d >= b:
v = d // b
d = v + d % b
s += v
print(s)
if __name__ == "__main__":
main()
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c, ans;
int main() {
scanf("%d%d", &a, &b);
while (a) {
ans += a;
int t = a + c;
a = t / b;
c = t % b;
}
printf("%d\n", ans);
return 0;
}
| 7 |
CPP
|
a,b=[int(i)for i in input().split()]
s=a
while(1):
c=a//b
a=c+(a%b)
s+=c
if(a<b):
break
print(s)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, w;
cin >> a >> b;
w = a;
while (w >= b) {
w = w - b + 1;
a++;
}
cout << a;
return 0;
}
| 7 |
CPP
|
m, n=map(int, input().split())
l=m
while l>n:
m+=l//n
l=l//n+l%n
if l==n:
m+=n//l
print(m)
| 7 |
PYTHON3
|
a, b = input().split()
a, b = int(a),int(b)
s = a
while int(a/b):
s +=int(a/b)
a = int(a/b) + a%b
print(s)
| 7 |
PYTHON3
|
from sys import stdin
a, b = map(int, stdin.readline().split())
res, tail = a, 0
while a:
a, tail = divmod(a + tail, b)
res += a
print(res)
| 7 |
PYTHON3
|
a,b=input().split()
count=0
a=int(a)
b=int(b)
m=a
rem=0
while(a!=0):
count+=a//b
rem+=a%b
a=a//b
if(a==0 and rem>=b):
a=rem
rem=0
print(count+m)
| 7 |
PYTHON3
|
#379A-New Year Candle
a,b=map(int,input().split(' '))
t=0
c=0
while True:
t+=a
d=int((a+c)/b)
c=(a+c) % b
a=d
if a == 0:
break
print(t)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
r = 0
while a > 0:
if a >= b:
r += b
a = a - b + 1
else:
r += a
a = 0
print(r)
| 7 |
PYTHON3
|
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 5 17:06:58 2019
@author: LV
"""
a, b = map(int, input().split())
t = ash = 0
while a > 0:
t += a
ash = ash + a
a, ash = ash // b, ash % b
print(t + a)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
hour,c = 0,0
while a:
hour += 1
a -= 1
c +=1
if c == b:
c = 0
a += 1
print(hour)
| 7 |
PYTHON3
|
l=list(map(int,input().split(" ")))
candles=l[0]
b=l[1]
time=0
waste=0
k=0
while(candles>0):
time=time+candles
waste=candles
candles=int((waste+k)/b)
k=(waste+k)%b
print(time)
| 7 |
PYTHON3
|
a,b = map(int, input().split())
c = a
d = 0
s = 0
while c:
s += c
d += c
c = d // b
d %= b
print(s)
| 7 |
PYTHON3
|
a, b = map(int, input().split()); ct = 0; i = 1
while a > 0:
a -= 1; ct += 1
if i % b == 0: a += 1
i += 1
print(ct)
| 7 |
PYTHON3
|
n,m=map(int,input().split())
count=n+(n-1)//(m-1)
print(count)
| 7 |
PYTHON3
|
a, b = [int(x) for x in input().split()]
hour = 1
broken = 0
while a != 0:
a -= 1
broken += 1
if broken == b:
broken = 0
a += 1
hour += 1
print(hour - 1)
| 7 |
PYTHON3
|
a,b=[int(i) for i in input().split()]
s=a
while(1):
s=int(s+a/b)
a=int((a/b)+(a%b))
if(a<b):
break
print(int(s))
| 7 |
PYTHON3
|
a,b=input().split( )
a=int(a)
b=int(b)
t=a
while a//b>=1:
t+=a//b
a=a//b+a%b
print(t)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
s=a
while a>=b:
s=s+a//b
a=a//b+a%b
print(s)
| 7 |
PYTHON3
|
a,b=map(int,input().split());d=lambda v:v//b and v//b+d(v//b+v%b);print(d(a*b))
| 7 |
PYTHON3
|
x=list(map(int,input().split()))
n=0
while x[0]!=n:
n+=1
if n%x[1]==0:
x[0]=x[0]+1
print(n)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
output=a
left=a
while left>=b:
output=output+(left//b)
left=(left//b)+(left%b)
print(output)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
ans=a
left=0
while(a>0):
while(a>0):
ans+=a//b
left+=a%b
a=a//b
if(left<b):
a=0
else:
a=left
left=0
print(ans)
| 7 |
PYTHON3
|
#379A
a,b=map(int,input().split())
num=a
while a >=b:
num+=a//b
a=(a%b)+a//b
print(num)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
ans=a
r=a
while r//b>=1:
ans=ans+r//b
r=r//b+r%b
print(ans)
| 7 |
PYTHON3
|
candle,remake=map(int,input().split())
hours=0
ToMake=0
made=0
if candle>=remake:
while hours<candle:
hours+=1
ToMake+=1
if ToMake==remake:
made+=1
ToMake=0
if candle<=hours:
candle+=made
made=0
print(candle)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
t = 0
e = 0
while a > 0 :
t += 1
a -= 1
e += 1
if e == b :
a += 1
e = 0
print(t)
| 7 |
PYTHON3
|
a, b = input().split()
a = int(a)
b = int(b)
c = 0
sum = a
while a > 0:
c += (a % b)
a = int(a / b)
if c >= b:
a += int(c / b)
c -= b
sum += a
print (sum)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
int main() {
int n, m;
scanf("%d %d", &n, &m);
int i, q, r, sum, days = (n / m) * m;
for (i = 1; i <= 10000; i++) {
q = n / m;
r = n % m;
sum = q + r;
n = sum;
days = days + (sum / m) * m;
if (sum / m == 0) {
days = days + sum % m;
break;
}
}
printf("%d", days);
}
| 7 |
CPP
|
a,b =[int(i) for i in input().split()]
k=0
t=0
while a>0:
t+=1
a-=1
k+=1
if k==b:
a+=1
k=0
print (t)
| 7 |
PYTHON3
|
a=list(map(int,input().split()))+[0,0]
while(a[0]>0)|(a[2]>a[1]):
a[0],a[2],a[3]=0,a[2]+a[0],a[3]+a[0]
a[0],a[2]=a[2]//a[1],a[2]%a[1]
print(a[3])
| 7 |
PYTHON3
|
a,b=map(int,input().split())
count=a
while a>0:
if a>=b:
a-=b
count+=1
a+=1
else:
break
print(count)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int a, b;
int sum;
int main() {
cin >> a >> b;
while (a >= b) {
sum += a / b * b;
a = a / b + a % b;
}
cout << sum + a;
return 0;
}
| 7 |
CPP
|
a, b = map(int,input().split())
s = 0
i = 0
while a > 0:
s = s + a
i = i % b
i = i + a % b
a = a // b + i //b
print(s)
| 7 |
PYTHON3
|
Candle_input=input("")
Candle_input = Candle_input.split(" ")
remaining_total = int(Candle_input[0]) #total candles
recharge = int(Candle_input[1]) #recharge for one candle
hours_of_light = 0
while (remaining_total>0):
if remaining_total >= recharge:
remaining_total = remaining_total - recharge
hours_of_light = hours_of_light + recharge
remaining_total = remaining_total + 1
else:
hours_of_light = hours_of_light + remaining_total
remaining_total = 0
print(hours_of_light)
| 7 |
PYTHON3
|
candels, b = [int(data) for data in input().split()]
hours = candels
candels_ends = candels
while candels_ends >= b:
candels = candels_ends // b
candels_ends = candels_ends - (candels * b)
hours = hours + candels
candels_ends = candels_ends + candels
print(hours)
| 7 |
PYTHON3
|
n,k = map(int,input().split())
i = 0
t = n
r = 0
while n >= k:
t = t + n//k
n = n//k + n%k
# print(t)
print(t)
| 7 |
PYTHON3
|
def New_Year_Candles(a, b):
ans = a + (a-1)//(b-1)
print(ans)
a, b = map(int, input().split())
New_Year_Candles(a, b)
| 7 |
PYTHON3
|
raw, recycle = map(int, input().split())
answer = raw
burnt = raw
while burnt//recycle != 0:
answer += burnt//recycle
burnt = burnt//recycle + burnt%recycle
print(answer)
| 7 |
PYTHON3
|
sum_in, ex = [int(x) for x in input().strip().split()]
cnt = sum_in
while sum_in >= ex:
cnt += int(sum_in/ex)
sum_in = int(sum_in/ex) + sum_in % ex
print(cnt)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
t=a
out=a
while out//b!=0:
t+=out//b
out=out-(out//b)*b+out//b
print(t)
| 7 |
PYTHON3
|
a,b=map(int,input().split())
h=a
while(a>=b):
h=h+a//b
a=(a//b)+(a%b)
print(h)
| 7 |
PYTHON3
|
a, b = map(int, input().split())
ans = 0
tmp = 0
while True:
ans += a
tmp += a
if tmp<b:break
a = tmp//b
tmp = tmp%b
print(ans)
| 7 |
PYTHON3
|
a,b = map(int,input().split())
count = a
c = a
while c >= b:
a = c // b
count += a
c %= b
c += a
print(count)
| 7 |
PYTHON3
|
a, b = map(int,input().split())
count = 0
used = 0
while a > 0:
a -= 1
count += 1
used += 1
if used == b:
a += 1
used = 0
print(count)
| 7 |
PYTHON3
|
A, B = map(int, input().split())
sum = 0
stock = 0
while True:
sum += A
if A+stock < B: break
newA = (A+stock) // B
stock = (A+stock) % B
A = newA
print(sum)
| 7 |
PYTHON3
|
line = input()
params = line.split(' ')
a = int(params[0])
b = int(params[1])
total_hours = a
candles = a
while candles >= b:
total_hours += int(candles / b)
candles = int((candles / b) + (candles % b))
print(total_hours)
| 7 |
PYTHON3
|
a = input().split()
ans, w = 0,0
for i in range(int(a[0])):
ans=ans+1
w=w+1
if w == int(a[1]):
w = 1
ans = ans +1
print(ans)
| 7 |
PYTHON3
|
a,b=map(int,input().split());print((a*b-1)//(b-1))
| 7 |
PYTHON3
|
a, b = map(int,input().split())
count = 0
total = a
while a >= b:
count = a // b
total += count
a = count + (a % b)
print(total)
| 7 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a = 0, b = 0;
cin >> a >> b;
int n_candles = a;
while (a / b) {
n_candles += a / b;
a = (a / b) + (a % b);
}
cout << n_candles << endl;
return 0;
}
| 7 |
CPP
|
n,m=map(int,input().split())
ans=n
while int(n):
ans+=n/m
n=n/m
print(int(ans))
| 7 |
PYTHON3
|
n,m=map(int,input().split())
print((n-1)//(m-1)+n)
| 7 |
PYTHON3
|
line = input().split()
a = int(line[0])
b = int(line[1])
hour = 0
total = a
burned = 0
while(total > 0):
total -= 1
burned += 1
if(burned % b == 0):
total += 1
hour += 1
print(str(hour))
| 7 |
PYTHON3
|
a,b=map(int,input().split())
sum=a
if a<b:
print(sum)
else:
while a>=b:
sum=sum+a//b
a=a//b+a%b
print(sum)
| 7 |
PYTHON3
|
a = [int(i) for i in input().split()]
sum = 0
sum += a[0]
b = sum
while b != 0:
if b >= a[1]:
b -= a[1]
b += 1
sum += 1
else:
b -= b
print(sum)
| 7 |
PYTHON3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.