Created
September 18, 2019 02:26
-
-
Save surinoel/e035a07996eee1351d56be4e84c31584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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