#include <string>
#include <vector>
#include <iostream>
using namespace std;
 
int solution(int n)
{
    // 자기 자신
    int answer = 1;
    
    for(int i = 1; i <= n/2; i++)
    {
        int sum = i;
        
        for(int j = i+1; j <= n/2+1; j++)
        {
            sum += j;
            
            // 합이 n인 경우 
            if(sum == n)
            {
                answer++;
                break;
            }
            // 합이 n보다 큰 경우
            else if(sum > n)
            {
                break;
            }
        }
    }
    
    return answer;
}
cs

+ Recent posts