I am solving the problem: Write a program to input positive integers n and k (n,k<=109). Print the smallest number divisible by k, greater than or equal to n. When i use code c++:
long long n,k;
cin>>n>>k;
cout<<(n+k-1)/k*k;
# return 0;
it works smoothly
but when i use code python :
n, k = map(int,input().split())
print((n+k-1)//k*k)
it is runtime
Why is it like that?
how to fix it and similar problems
New contributor
Đạt Phạm Thành is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.