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; }
6 Answers
+ 3
where is the problem statement
+ 1
What is the problem statwment?
+ 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...
+ 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?