스터디/알고리즘

[백준 4375] 1

덩이 2022. 5. 15. 01:47
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int temp=0;
        for(int i=1; i<=n; i++){
            temp = (temp*10)+1;
            temp %= n;
            if(temp == 0){
                cout << i << "\n";
                break;
            }
        }
    }
    return 0;
}

곱하기 10을 하면서 1을 더한 것을 모듈 연산을 하고 

n으로 나눴을때 0인 것을 출력