Saturday, 2 June 2012

UVa 10170 The Hotel with Infinite Rooms Solution

#include<stdio.h>
int main()
{
long s,d,i,n;
while(scanf("%ld%ld",&s,&d)==2)
{
n=0;
for(i=s;;i++)
{
n+=i;
if(n>d || n==d)
{
printf("%ld\n",i);
break;
}
}
}
return 0;
}

No comments:

Post a Comment