728x90
SMALL

using System;
using System.Collections.Generic;

public class Solution {
    public int solution(int number, int limit, int power) {
        int answer = 0;
        int num = 0;
        int[] count = new int[number + 1];
        
        for(int i = 1; i <= number; i++)
        {
            for(int j = i;j<=number;j+=i)
            {
                count[j]++;
            }
        }
        
        for(int i = 0; i <= number; i++)
        {
            if(count[i] > limit)
            {
                answer += power;
            }
            else
            {
                answer += count[i];
            }
        }
        return answer;
    }
}

 

////

using System;

public class Solution {
    public int solution(int number, int limit, int power) {
        int answer = 0;
        int anw = 0;

        for(int j = 1 ;j <= number ;j++) //count is current number ,  number is final number
        {
                for(int i = 1; i <= j; i++)
                {
                    if(i > j/2+1)
                    {
                        anw++;
                        break;
                    }
                    if(j % i == 0)
                    {
                        anw++;
                    }

                }
            if(anw > limit)
            {
                anw = power;
            }
            answer += anw;
            anw = 0;
        }
        return answer;
    }
}
728x90

설정

트랙백

댓글