Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerEarth Picu Bank problem solution

YASH PAL, 31 July 2024
In this HackerEarth Picu Bank problem solution, You have D dollars with you. You want to put it into a Bank, namely Picu Bank. This bank has a peculiar behavior for interest. Regardless of the Bank deposit amount, every month it adds A dollars to your bank account and this continues till M months. Exaxtly on M + 1 months, it adds B dollars (B < A) to your bank account. This scanario repeats again in same manner.( i.e on the (M + 2)th month A dollars are added, and so on.. ). Your task is to find out how many months does it take for the dollar amount to reach at least X, in the bank account.
HackerEarth Picu Bank problem solution

HackerEarth Picu Bank problem solution.

#include<bits/stdc++.h>
#define Y second
#define mpp make_pair
#define nl printf("n")
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define all(v) v.begin(),v.end()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define fr(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
#define MX 1004
#define inf 10000000000
#define MD 1000000007LL
#define eps 1e-9

ll D,A,M,B,X;
int main() {
int tc,cs=1,q,i,j;
S(tc);
assert(tc<=100000);
assert(tc>=1);
while(tc--){
SL2(D,A);
SL2(M,B);
SL(X);
assert(B<A);
assert(A>=1);
assert(B>=1 && B<=1000000000);
assert(M>=1 && M<=1000000000);
assert(X>=1 && X<=1000000000);
assert(A>=1 && A<=1000000000);
if( X<=D ){
printf("0n");
continue;
}
X-=D;
ll dd=(M*A+B);
assert(dd>=1);
ll tot=(X/dd);
ll money=tot*dd;
ll ans=(tot*(M+1));
ll rem=X;
if( money )rem=(X%money);
if(rem==0){
printf("%lldn",ans);
continue;
}
ans+=(ll)(ceil(rem*1.0/A*1.0));
printf("%lldn",ans);
}
return 0;
}
coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes