자릿수를 증가시켜가며 나누어 떨어지는지 확인한다.
#include <bits/stdc++.h>
using namespace std;
int com;
long long ret, n;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
while(cin >> com){
n = 1; ret = 1;
while(n%com != 0){
n = 10*n + 1;
n %= com;
ret++;
}
cout << ret << "\n";
}
return 0;
}