728x90
SMALL

using System;

public class Solution {
    public int solution(int a, int b, int n) {
        int answer = 0;
        int index = n;
        
        while(n > n%a)
        {
            answer += (n/a)*b;
            n = n%a+(n/a)*b;
        }
        
        return answer;
    }
}

 

/////

 

public class Solution {
    public int solution(int a, int b, int n) {
        return (n > b ? n - b : 0) / (a - b) * b;
    }
}

 

파이썬

//////

 

def solution(a, b, n):
    answer = 0
    while n >= a:
        answer += (n // a) * b
        n = (n // a) * b + (n % a)
    return answer

 

자바

 

class Solution {
    public int solution(int a, int b, int n) {
        int answer = 0;

        while (n >= a) 
        {
            answer += b * (n / a);
            n = b * (n / a) + n % a;
        }

        return answer;
    }
}

 

 

728x90

설정

트랙백

댓글