#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n, mul, ans;
while(~scanf("%d", &n)){
int mod = 1;
for(int i = 1; ; i++){
mod = (((mod%n) * (10%n))%n + 1)%n;
if(!mod){
ans = i+1;
break;
}
}
cout << ans << endl;
}
return 0;
}
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n, mul, ans;
while(~scanf("%d", &n)){
int mod = 1;
for(int i = 1; ; i++){
mod = (((mod%n) * (10%n))%n + 1)%n;
if(!mod){
ans = i+1;
break;
}
}
cout << ans << endl;
}
return 0;
}
No comments:
Post a Comment