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

Beautrip, Product From Mastercard Hackathon Singapore

Last 2 weeks, me and my friend muhar participated on Master Card Hackathon Singapore. Hackathon itself placed in 237.io coworking space, the place itself located exactly in front of Sri Mariamman Temple Theme of this hackathon is Empower... Continue →