Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • 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
Programmingoneonone

Learn everything about programming

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

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes