UVA 846
#include<iostream> using namespace std; int main() { int sum; cin>>sum; while(sum--) { int m,n,i; cin>>m>>n; int dis=n-m; if(dis==0) cout<<"0"<<endl; else { for(i=0;;i++) { if(dis==i*i) { cout<<2*i-1<<endl; break; } else if(dis>i*i&&dis<(i+1)*(i+1)) { if(dis<=i*(i+1)) { cout<<2*i<<endl; break; } else { cout<<2*i+1<<endl; break; } } } } } return 0; }