Guest User

Untitled

a guest
Aug 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PicuBank {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. int t = sc.nextInt();
  8. while (t-- > 0) {
  9. int d = sc.nextInt();
  10. int a = sc.nextInt();
  11. int m = sc.nextInt();
  12. int b = sc.nextInt();
  13. int x = sc.nextInt();
  14. System.out.println(check(d, a, m, b, x));
  15. }
  16. }
  17.  
  18. private static int check(int d, int a, int m, int b, int x) {
  19. int months = 0;
  20. int direct = (a*m)+b;
  21. int dir_months = m+1;
  22. int dhan_rashi = d;
  23. while (dhan_rashi < x) {
  24. if (months != 0 && months % m == m - 1) {
  25. dhan_rashi += b;
  26. dhan_rashi += a;
  27. months += 2;
  28. // System.out.println(dhan_rashi + "-->" + months);
  29. }
  30. if (months % m != m - 1 || months == 0) {
  31. dhan_rashi += a;
  32. months++;
  33. // System.out.println(dhan_rashi+ "-->" + months);
  34. }
  35. }
  36. return months;
  37. }
  38.  
  39. }
Add Comment
Please, Sign In to add comment