Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created September 18, 2019 02:26
Show Gist options
  • Save surinoel/e035a07996eee1351d56be4e84c31584 to your computer and use it in GitHub Desktop.
Save surinoel/e035a07996eee1351d56be4e84c31584 to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
while (cin >> n) {
if (n == 1) {
cout << 1 << '\n';
continue;
}
int cnt = 2;
long long div = 1;
while (div = ((div * 10) % n + 1) % n) {
cnt += 1;
}
cout << cnt << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment