본문 바로가기

알고리즘/백준

백준 1110 - 더하기 사이클(브론즈I)

반응형

문제출처 : https://www.acmicpc.net/source/10769662

 

로그인

 

www.acmicpc.net

<문제풀이>

10진수의 자리를 분해 할 수 있는지 체크하는 문제

#include <iostream>
#include <cstdio>
#include <string.h>

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    if(n<10) n*=10;
    int next = n;
    int cnt = 0;
    do{
        int a,b;
        a = next / 10;
        b = next % 10;
        next = b * 10 + (a + b) % 10;
        cnt++;
    }while(next!=n);
    printf("%d",cnt);

    return 0;
}
반응형