#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; // 入力 n が1の場合は、任意の k で 10^k % 1 == 0 となるため、条件が成立しませんが、 // ここでは特別に k=1 として出力する例です。 if(n == 1){ cout << 1 << "\n"; return 0; } int k = 1; // 10^k mod n の初期値 int mod = 10 % n; while(mod != 1) { mod = (1LL * mod * 10) % n; k++; } cout << k << "\n"; return 0; }