Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PicuBank {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int t = sc.nextInt();
- while (t-- > 0) {
- int d = sc.nextInt();
- int a = sc.nextInt();
- int m = sc.nextInt();
- int b = sc.nextInt();
- int x = sc.nextInt();
- System.out.println(check(d, a, m, b, x));
- }
- }
- private static int check(int d, int a, int m, int b, int x) {
- int months = 0;
- int direct = (a*m)+b;
- int dir_months = m+1;
- int dhan_rashi = d;
- while (dhan_rashi < x) {
- if (months != 0 && months % m == m - 1) {
- dhan_rashi += b;
- dhan_rashi += a;
- months += 2;
- // System.out.println(dhan_rashi + "-->" + months);
- }
- if (months % m != m - 1 || months == 0) {
- dhan_rashi += a;
- months++;
- // System.out.println(dhan_rashi+ "-->" + months);
- }
- }
- return months;
- }
- }
Add Comment
Please, Sign In to add comment