SRM 629 Div 2 1000 Points

If you are following the topcoder SRM 629 div 2 this is the source code

public class CandyAddict {

public static void main(String[] args) {
    solve(new int[]{1000000000,1000000000,1000000000,1000000000,1000000000},
            new int[]{1,2,3,999999998,999999999},
    new int[]{342568368,560496730,586947396,386937583,609483745});

}

public static  long [] solve(int[] X, int[] Y, int[] Z){
    int qLength = X.length;
    long [] result = new long[qLength]; 
    for (int i = 0; i < qLength; i++) {
        long money = 0;
        long candy = 0;
        for (int j = 0; j < Z[i]; j++) {
            money += X[i];
            if (candy <= 0){
                candy = money / Y[i];
                money = money % Y[i];
            }
            if (candy > 0){
                candy -=1;
            }
        }
        result[i] = money;
        System.out.println(money);

    }

    return result;
}

}

 
4
Kudos
 
4
Kudos

Now read this

Facebook Hacker Cup Qualification Round

Last weekend i’m participating on Facebook Hacker Cup, and the first stage is qualification round. If you managed to answer one of the problem you can pass to next round. In Qualification round there is 3 problems : Cooking Books... Continue →