정수가 담긴 리스트 num_list가 주어질 때, 모든 원소들의 곱이 모든 원소들의 합의 제곱보다 작으면 1을 크면 0을 return하도록 solution 함수를 완성해주세요.
2 ≤ num_list의 길이 ≤ 10
1 ≤ num_list의 원소 ≤ 9
num_list result
[3, 4, 5, 2, 1] 1
[5, 7, 8, 3] 0
입출력 예 #1
모든 원소의 곱은 120, 합의 제곱은 225이므로 1을 return합니다.
입출력 예 #2
모든 원소의 곱은 840, 합의 제곱은 529이므로 0을 return합니다.
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
// num_list_len은 배열 num_list의 길이입니다.
int solution(int num_list[], size_t num_list_len) {
int times = 1;
int plus = 0;
for (int i = 0; i < num_list_len; i++) {
times *= num_list[i];
plus += num_list[i];
}
return times < plus * plus;
}