題目鏈接
題意:求出多少個1組成的數字能整除n
思路:一位位去取模,記錄答案即可
代碼:
#include
#include
int n;
int main() {
while (~scanf("%d", &n)) {
int ans = 1;
int now = 1;
while (now) {
now = (now * 10 + 1) % n;
ans++;
}
printf("%d\n", ans);
}
return 0;
}