Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.text.*;
- import java.math.*;
- import java.util.regex.*;
- class Solution {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int t = in.nextInt();
- for(int i = 0; i < t; i++){
- System.out.println(Solve(in.nextInt(), in.nextInt(), in.nextInt()));
- }
- }
- private static long Solve(int t, int p, int w){
- long wC=0,c=0;
- c=t/p;
- wC=c;
- while(wC>=w){
- c+=wC/w;
- wC+=wC/w;
- wC=wC-w;
- }
- return c;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement