Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 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 in = new Scanner(System.in);
  8. long n = in.nextInt();
  9. long c = in.nextInt();
  10. long u = in.nextInt();
  11. long s = in.nextInt();
  12. long n2 = n;
  13. long c2 = c;
  14.  
  15. long max, count3;
  16. long count1 = c/u;
  17. // int i = 0;
  18. // while(u*n > c){
  19. // n--;
  20. // c+=s;
  21. // long x = c/u;
  22. // if(n<c) {
  23. // break;
  24. // }
  25.  
  26. // }
  27. n2 = n-count1;
  28. long remainingC = c%u;
  29. long upgradabel = 0;
  30. do{
  31. while(remainingC<u){
  32. n2--;
  33. remainingC+=s;
  34. }
  35. count1++;
  36. System.out.println(count1);
  37. remainingC-=u;
  38. if(u>remainingC) break;
  39. if(n2<0) break;
  40. }while(true);
  41.  
  42. long count2 = c2/u;
  43. count3 =count1 + count2;
  44.  
  45. if(count3>n) max=count3;
  46. else max=n;
  47. System.out.println(count1);
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement