#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b){
double x1,y1,x2,y2;
if(!a)
x1=0,y1=0;
else{
long long col=sqrt(a);
if(col&1)
if(a&1)
y1=col*sqrt(3)/2;
else
y1=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
if(a&1)
y1=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
y1=col*sqrt(3)/2;
}
if(!b)
x2=0,y2=0;
else{
long long col=sqrt(b);
if(col&1)
if(b&1)
y2=col*sqrt(3)/2;
else
y2=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
if(b&1)
y2=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
y2=col*sqrt(3)/2;
}
x1=a-(int)sqrt(a)*(int)sqrt(a)-(int)sqrt(a);
x2=b-(int)sqrt(b)*(int)sqrt(b)-(int)sqrt(b);
x1/=2,x2/=2;
cout<<fixed<<setprecision(3)<<double(round(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))*1000))/1000<<endl;
}
}
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
int a,b;
while(cin>>a>>b){
double x1,y1,x2,y2;
if(!a)
x1=0,y1=0;
else{
long long col=sqrt(a);
if(col&1)
if(a&1)
y1=col*sqrt(3)/2;
else
y1=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
if(a&1)
y1=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
y1=col*sqrt(3)/2;
}
if(!b)
x2=0,y2=0;
else{
long long col=sqrt(b);
if(col&1)
if(b&1)
y2=col*sqrt(3)/2;
else
y2=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
if(b&1)
y2=(col-1)*sqrt(3)/2+sqrt(3)/3;
else
y2=col*sqrt(3)/2;
}
x1=a-(int)sqrt(a)*(int)sqrt(a)-(int)sqrt(a);
x2=b-(int)sqrt(b)*(int)sqrt(b)-(int)sqrt(b);
x1/=2,x2/=2;
cout<<fixed<<setprecision(3)<<double(round(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))*1000))/1000<<endl;
}
}
Comments
Post a Comment