Short Cake
8PM - Animal Crossing Wild World

사생활 보호 설정

https://gamjia.tistory.com

Mini Rooms

  • 내 미니룸
  • 미니미설정
  • 미니룸설정
  • 답글수 [0]

What Friends Say

한마디로 표현해봐~

1촌평 관리

2231번 분해합

GamJia 2023. 3. 31. 09:17

단계별로 풀어보기 - 브루트 포스 - 2단계

https://www.acmicpc.net/problem/2231

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    
    for(int i=1;i<N;i++)
    {
        int temp=i;
        int count=i;
        
        while(temp>0)
        {
            count+=temp%10;
            temp/=10;
        }
        
        if(count==N)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    
    if(N!=0)
    {
        cout<<0<<endl;
    }    
}

'BaekJoon' 카테고리의 다른 글

1018번 체스판 다시 칠하기  (0) 2023.04.03
7568번 덩치  (0) 2023.04.03
2798번 블랙잭  (0) 2023.03.31
11729번 하노이 탑 이동 순서  (0) 2023.03.31
2447번 별 찍기  (0) 2023.03.31