Guest User

Untitled

a guest
Mar 15th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8.     public static void main (String[] args) throws java.lang.Exception
  9.     {
  10.         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  11.  
  12.         int zestawy = 0;
  13.         try {
  14.             zestawy = Integer.valueOf(bf.readLine());
  15.         } catch (IOException e) {
  16.             e.printStackTrace();
  17.         }
  18.  
  19.         double dzieciak = 0;
  20.  
  21.         double[] returnArray = new double[zestawy];
  22.  
  23.         for (int i = 0; i < zestawy; i++) {
  24.  
  25.             String input = null;
  26.             try {
  27.                 input = bf.readLine();
  28.             } catch (IOException e) {
  29.                 e.printStackTrace();
  30.             }
  31.             if (input.equals(null)) {
  32.                 break;
  33.             }
  34.  
  35.  
  36.             String[] inputArray = input.split(" ");
  37.  
  38.  
  39.  
  40.             double oIleStarszaMatka = Integer.valueOf(inputArray[0]);
  41.             double zaIleLat = Integer.valueOf(inputArray[1]);
  42.             double ileRazyBedzieStarsza = Integer.valueOf(inputArray[2]);
  43.  
  44.             double leftSide = oIleStarszaMatka+zaIleLat;
  45.             double rightSide = zaIleLat*ileRazyBedzieStarsza;
  46.             dzieciak = (rightSide - leftSide) / (ileRazyBedzieStarsza - 1);
  47.  
  48.             dzieciak = Math.round(12 * dzieciak);
  49.  
  50.  
  51.  
  52.             returnArray[i] = dzieciak;
  53.  
  54.         }
  55.  
  56.         for (double i : returnArray) {
  57.             System.out.println((int) i);
  58.  
  59.  
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment