problem link:
Discuss: In this problem you can use while loop.substitute s from d while d greater then 0.and increase s with one in every loop then print s-1 the number of team members on this day
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long s,d,i,j,cnt=0;
while((cin >>s>>d))
{
cnt=0;
while(d>0)
{
d-=s;
s+=1;
if(d<0)
break;
}
cout <<s-1<<endl;
}
return 0;
}
Discuss: In this problem you can use while loop.substitute s from d while d greater then 0.and increase s with one in every loop then print s-1 the number of team members on this day
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long s,d,i,j,cnt=0;
while((cin >>s>>d))
{
cnt=0;
while(d>0)
{
d-=s;
s+=1;
if(d<0)
break;
}
cout <<s-1<<endl;
}
return 0;
}
No comments:
Post a Comment