[BOJ] 2231 분해합

Time Lapse :NONE

2231.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <math.h>

int answer = 0;

int func_answer(int num, int cur, int devied_cur)
{
int func_cur=cur+(devied_cur%10);

if(devied_cur==0&&num==cur)
return 1;
else if(devied_cur==0)
return 0;

return func_answer(num,func_cur,devied_cur/10);
}

int main(void)
{
int num;
int i;

scanf("%d",&num);

for(i = 0; i < num; i++)
{
if(func_answer(num, i, i))
{
answer = i;
break;
}
}

printf("%d\n",answer);
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/2231/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.