Devlog
article thumbnail
Published 2022. 5. 15. 01:47
[백준 4375] 1 스터디/알고리즘
#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인 것을 출력

'스터디 > 알고리즘' 카테고리의 다른 글

[백준 11655] ROT13  (0) 2022.06.21
[백준 1159] 농구 경기  (0) 2022.05.15
[백준 1629] 곱셈  (0) 2022.05.14
[백준 10988] 팰린드롬인지 확인하기  (0) 2022.05.11
[백준 10808] 알파벳 개수  (0) 2022.05.11
profile

Devlog

@덩이

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

검색 태그