Advertisement
mirozspace

Pr1

Jan 20th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pr1PartyProfit {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int companions = Integer.parseInt(scanner.nextLine());
  8.         int days = Integer.parseInt(scanner.nextLine());
  9.         int coins = days * 50;
  10.  
  11.         for (int i = 1; i <= days; i++) {
  12.  
  13.             if (i % 10 == 0) {
  14.                 companions -= 2;
  15.             }
  16.             if (i % 15 == 0) {
  17.                 companions += 5;
  18.             }
  19.             if (i % 3 == 0) {
  20.                 coins -= companions * 3;
  21.             }
  22.             if (i % 5 == 0) {
  23.                 coins += 20 * companions;
  24.                 if (i % 3 == 0) {
  25.                     coins -= companions * 2;
  26.                 }
  27.             }
  28.             coins -= companions * 2;
  29.         }
  30.  
  31.         int coinsPerPerson = coins / companions;
  32.         System.out.printf("%d companions received %d coins each.",companions ,coinsPerPerson);
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement