Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import java.text.*;
  4. import java.math.*;
  5. import java.util.regex.*;
  6.  
  7. class Solution {
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner in = new Scanner(System.in);
  11.         int t = in.nextInt();
  12.         for(int i = 0; i < t; i++){
  13.             System.out.println(Solve(in.nextInt(), in.nextInt(), in.nextInt()));
  14.         }
  15.     }
  16.    
  17.     private static long Solve(int t, int p, int w){
  18.         long wC=0,c=0;
  19.         c=t/p;
  20.         wC=c;
  21.         while(wC>=w){
  22.             c+=wC/w;
  23.             wC+=wC/w;
  24.             wC=wC-w;
  25.         }
  26.         return c;
  27.     }
  28.    
  29.    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement