This commit is contained in:
2025-12-28 12:04:25 +08:00
parent c0efe232d6
commit 5297b42c6e
4 changed files with 62 additions and 0 deletions

17
25/12/comp/28q3.cpp Normal file
View File

@@ -0,0 +1,17 @@
class Solution {
public:
int minAllOneMultiple(int k) {
if (k%2==0 || k%5==0) {
return -1;
}
int remainder = 1;
for (int i = 1 ;i<=k;i++) {
if (remainder % k == 0) {
return i;
}
// (a * 10 + 1) % k = ((a % k) * 10 + 1) % k
remainder = (remainder * 10 + 1) % k;
}
return -1;
}
};