PersonalCorpus 版 (精华区)
Your C++ program has solved Ok the problem 846 (Steps)
in 0.010 seconds with low memory spent.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <ctype.h>
void main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input846.txt","r",stdin);
freopen("c:\\uva\\output846.txt","w",stdout);
#endif
int i,j,k,n;
scanf("%d\n",&n);
while (n>0) {
n--;
scanf("%d%d\n",&i,&j);
k=j-i;
if (k==0) { printf("0\n"); continue; }
i=(int)sqrt(k);
k-=i*i;
j=i+i-1;
if ((k<=i)&&(k>0)) j++;
if (k>i) j+=2;
printf("%d\n",j);
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:6.433毫秒