Comments
On KluydQCodeforces Round 1076 (Div. 3), 3 months ago
+1

True, I got confused with the meaning of sword strikes.

For any integer a and b with gcd(a,b)=D, there always exists integers x and y, such that ax + by = D. And here we can use gcd, as D is also bounded by K,in other words (ax + by)mod K = D mod K, so there always exists non-negative x and y.

If we take gcd(a1,a2,...,an,K)=S, we will get the smallest last digit(other than 0) which we can be obtained using the denominations ( K is also included in the gcd because we need the last digit which is bounded by K).

So multiples of S less than K will be the answer because there are the number of denominations are infinite.