Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Solution {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int p = sc.nextInt(), d = sc.nextInt(), m = sc.nextInt(), v = sc.nextInt(), total = 0;
- for(int i = 0; v >= 0; i++) {
- if (i == 0) v -= p;
- else v -= Math.max(p - d * i, m);
- total++;
- }
- System.out.println(--total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement