Advertisement
Yesver08

Keju Mozarella Khas Malang

Jan 30th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Solution {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         int p = sc.nextInt(), d = sc.nextInt(), m = sc.nextInt(), v = sc.nextInt(), total = 0;
  9.         for(int i = 0; v >= 0; i++) {
  10.             if (i == 0) v -= p;
  11.             else v -= Math.max(p - d * i, m);
  12.             total++;
  13.         }
  14.         System.out.println(--total);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement