0

How solve this problem without while loop...??

int main() { int n,d,b1,b2,c=0,v; cin>>n>>d>>b1; for(int i=1;i<n;i++) { cin>>b2; while(b2<=b1) { b2=b2+d; c++; } b1=b2; } cout<<c; c=0; return 0; }

20th Nov 2017, 1:15 AM
Sabbir Hossain
Sabbir Hossain - avatar
6 Answers
+ 3
where is the problem statement
20th Nov 2017, 1:35 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 1
What is the problem statwment?
20th Nov 2017, 1:23 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
if i use while loop then got a time limit in a online judge...thats why try to solve the problem without while loop...
20th Nov 2017, 1:34 AM
Sabbir Hossain
Sabbir Hossain - avatar
+ 1
This is the problem statement... ## A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t. You are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?
20th Nov 2017, 1:36 AM
Sabbir Hossain
Sabbir Hossain - avatar