We need to compute the minimum positive integer x such that x is divisible by n, and x ends with at least k zeros in base 10 (i.e., x is a multiple of 10^k). Equivalent: x is a common multiple of n and 10^k, and we want the least positive common multiple, i.e., the least common multiple (LCM) of n and 10^k? But careful: The condition "ends with k or more zeros" means x is divisible by 10^k. However, if there exists a smaller number that is divisible by n and also a multiple of 10^k, it's the LCM of n and 10^k. But is it always the LCM? Let's see: For x to be divisible by n and 10^k, x must be a multiple of lcm(n, 10^k). The smallest positive such x is exactly lcm(n, 10^k). However, there is nuance: The requirement is "ends with k or more zeros". That means x's decimal representation ends with at least k zeros. That is equivalent to x being divisible by 10^k. So x must be a multiple of both n and 10^k. Hence the set of such x is exactly the set of multiples of L = lcm(n, 10^k). The smallest positive is L. So answer = lcm(n, 10^k).
But wait: Could there be a number that ends with more than k zeros but is smaller than L? Example: n=2, k=1. 10^k=10. lcm(2,10)=10. That is indeed the smallest number divisible by 2 and ending with at least one zero: 10. But 20 ends with one zero but is bigger. So ok. Another: n=5, k=2: 10^2=100, lcm(5,100)=100. Is there a smaller number divisible by 5 and ending with at least 2 zeros? 0? but positive. 100 is smallest. n=20, k=2: 10^2=100, lcm(20,100)=100? lcm(20,100)=100? Actually lcm(20,100)=100 because 20 divides 100. So answer=100. But is there a smaller number divisible by 20 and ending with at least two zeros? 0? positive? 20 ends with one zero, not at least two. 40 ends with one zero. 60,80,100. So 100 is correct. So L is answer.
But careful: If n itself ends with more than k zeros, e.g., input: 10000 1, output should be 10000 (the example). LCM(10000,10)=? 10000 is divisible by 10, so lcm(10000,10)=10000. Good.
If k=0, then 10^0=1. LCM(n,1)=n. So answer = n. matches example: 38101 0 -> 38101.
So answer = n * (10^k / gcd(n, 10^k)). Actually lcm(n, m) = n * m / gcd(n, m). So answer = n * (10^k) / gcd(n, 10^k).
But careful: 10^k can be huge for k up to 8: 10^8 = 100,000,000, which fits within 32-bit signed (100 million), but n up to 1e9, product n*10^k can be up to 1e9 * 1e8 = 1e17, which is beyond 64-bit? 1e17 < 2^63 (9.22e18). So it fits in 64-bit signed (long long in C++). Actually 1e17 is 100,000,000,000,000,000, which is 17 digits, 2^63-1 ~9.22e18, so fits. So we can compute using 64-bit (unsigned long long). However we could also compute as: compute d = gcd(n, 10^k). Then multiply n by (10^k / d). But we need to be careful about overflow if we compute 10^k first: 10^8 is fine. But if n is 1e9 and d small, product = 1e9 * 1e8 = 1e17, fits 64-bit. So okay.
But there is nuance: For k up to 8, 10^k fits in 32-bit. So we can compute:
Let pow10 = 1; for i in 1..k pow10 *=10.
Then d = gcd(n, pow10). Then answer = n / d * pow10. But must ensure multiplication does not overflow if using 32-bit? n / d * pow10 could be up to (1e9) * (1e8) = 1e17, need 64-bit. So we should use long long (or int64_t). In many languages, we can handle.
Alternatively, we can compute the answer by counting factors of 2 and 5 in n and complementing to achieve at least k zeros. Because requirement "ends with at least k zeros" means x is divisible by 2^k and 5^k? Actually 10^k = 2^k * 5^k. So x must be divisible by n and by 2^k and 5^k. To minimize x, we need to multiply n by the smallest factor such that the resulting number has at least k factors of 2 and k factors of 5. Essentially, let a = exponent of 2 in n, b = exponent of 5 in n. Then to have at least k of each, we need to add extra 2's and 5's: extra2 = max(0, k - a), extra5 = max(0, k - b). Then x = n * (2^{extra2}) * (5^{extra5}). That's equivalent to LCM: because lcm(n, 10^k) = n * (2^k / 2^{min(a,k)}) * (5^k / 5^{min(b,k)})? Actually factor: n = 2^a * 5^b * m, where m coprime to 10. Then lcm(n, 2^k * 5^k) = 2^{max(a,k)} * 5^{max(b,k)} * m. That equals n * 2^{max(a,k)-a} * 5^{max(b,k)-b} = n * 2^{extra2} * 5^{extra5}. So it's the same. This approach avoids computing large pow10 and gcd, but still product may be large. But we can compute using pow10 directly or via multiplication.
Given constraints, either method is fine.
But careful: The condition "ends with k or more zeros" means the decimal representation ends with at least k zeros. This is equivalent to divisibility by 10^k? Yes, because if a number ends with exactly t zeros, it is divisible by 10^t but not by 10^{t+1}. But "at least k zeros" means divisible by 10^k, but not necessarily not divisible by 10^{k+1}. So yes.
Thus answer = lcm(n, 10^k).
Now we need to write a program that reads two integers n and k, computes and prints the k-rounding.
Implementation details:
- Read n, k (int, int).
- Compute pow10 = 1; for i in range(k): pow10 *= 10. Or use precomputed array: [1,10,100,...] or use pow(10,k) but careful with floating point.
- Compute d = gcd(n, pow10).
- result = n / d * pow10. Must ensure integer division. Use long long for result.
Alternatively, using factor method:
- Count a = exponent of 2 in n; while n%2==0? but careful we need n's factorization, but n might be large, but we can just count while n%2==0, then divide. But we also need to preserve n's cofactor? Actually we need to compute the final multiplication. Better to compute extra2 and extra5. Then compute multiplier = 1; for i in 1..extra2: multiplier*=2; for i in 1..extra5: multiplier*=5; result = n * multiplier. But that could overflow? But we can use long long. Or we can compute result = n * (1 << extra2) * pow(5, extra5). For extra2 up to maybe 8, 2^8=256, fine. extra5 up to 8, 5^8 = 390625. So product n * (2^extra2 * 5^extra5) is similar. This approach avoids computing pow10 and gcd, but it's simple enough.
Edge case: k=0, then extra2=0, extra5=0, multiplier=1, result=n.
Check examples:
n=375, k=4: Factor 375 = 3 * 5^3? Actually 375 = 3 * 125 = 3 * 5^3. So a=0 (no factor 2), b=3. extra2 = max(0,4-0)=4, extra5 = max(0,4-3)=1. multiplier = 2^4 * 5^1 = 165=80. n80=30000. Yes.
n=10000, k=1: 10000 = 10^4 = 2^4 * 5^4. a=4,b=4. extra2 = max(0,1-4)=0, extra5=0. multiplier=1. result=10000.
n=38101, k=0: extra2=0,extra5=0 => result=n.
n=123456789, k=8: n is odd and not divisible by 5, so a=0,b=0, extra2=8, extra5=8, multiplier = 2^8 * 5^8 = (2*5)^8 = 10^8 = 100000000. result = 123456789 * 100000000 = 12345678900000000. matches.
So the factor method is straightforward and avoids gcd and pow10.
But both are trivial.
Given constraints, it's safe to compute result as n multiplied by 10^k / gcd(n,10^k). That might be slightly simpler to implement if using built-in gcd.
Which to choose? In Python, you can just compute lcm directly. But the problem is likely in C++? The user asked: "Write a program that will perform the k-rounding of n." Could be in any language. But since it's a typical competitive programming problem, we can provide solution in C++ or Python. We'll provide solution in Python for readability.
Thus algorithm: read n, k. Compute pow10 = 10**k. Compute g = math.gcd(n, pow10). answer = n // g * pow10. Print answer.
But careful: In Python, pow10 can be large but Python handles big integers. For k up to 8 it's fine.
Alternatively, compute using exponent method:
cnt2 = 0, cnt5 = 0; temp = n; while temp%2==0: cnt2+=1; temp//=2; while temp%5==0: cnt5+=1; temp//=5; extra2 = max(0, k-cnt2); extra5 = max(0, k-cnt5); answer = n * (2extra2) * (5extra5); print(answer).
Both are O(log n) basically.
Let's implement in Python.
We need to ensure reading input: two integers separated by space.
Edge Cases: k=0 => pow10=1, gcd = 1? Actually gcd(n,1)=1, answer = n*1/1 = n. Good.
Now output: print as integer.
Let's also consider possible overflow in C++: but we are doing Python, so big ints ok.
We'll produce a final answer with explanation and code.
But the instruction says "Write a program that will perform the k-rounding of n." Possibly they expect code only? The user is likely seeking solution. Provide solution in Python (or optionally C++). Since no language specified, we can provide Python.
Thus final answer: Provide explanation and code.
We'll write:
def k_rounding(n, k):
pow10 = 10**k
from math import gcd
return n // gcd(n, pow10) * pow10
Then read input and print.
Edge Cases: none.
That's it.
But wait: Could there be any pitfalls? For example, if n=0? But n positive integer (1 ≤ n ≤ 10^9). So n>=1.
Time complexity: O(log min(n,10^k)) for gcd, which is negligible.
Now, let's produce final output.
However, the user gave examples and expects output. So we should output the code.
We need to produce final answer with code block.
Also maybe include comment.
I'll produce final answer in Python 3.
Alternatively, could produce C++ code, but Python is typical for simplicity.
Will produce:
import sys
import math
def main():
data = sys.stdin.read().strip().split()
if not data: return
n = int(data[0]); k = int(data[1])
t = 10**k
g = math.gcd(n, t)
ans = n // g * t
print(ans)
if name == "main":
main()
That should work.
Check examples:
Input: 375 4 -> t=10000, gcd(375,10000)=? 375 and 10000: gcd=125? Actually 10000/125=80, 375/125=3, so gcd=125. ans=375//12510000=310000=30000. Yes.
Input: 10000 1 -> t=10, gcd(10000,10)=10, ans=10000//1010=100010=10000. Yes.
Input: 38101 0 -> t=1, gcd(38101,1)=1, ans=38101//1*1=38101.
Input: 123456789 8 -> t=100000000, gcd(123456789,100000000)=1 because 123456789 is odd and not divisible by 5, so gcd=1. ans=123456789*100000000=12345678900000000.
Works.
Thus answer.
We might want to mention that result may be large, but Python handles big integers.
Thus final.
```python
import sys
import math
def main():
data = sys.stdin.read().strip().split()
if not data:
return
n = int(data[0])
k = int(data[1])
pow10 = 10 ** k
g = math.gcd(n, pow10)
ans = n // g * pow10
print(ans)
if name == "main":
main()