http://acm.hdu.edu.cn/showproblem.php?pid=2073

  代码如下:

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;

double d[10005], D[10005];

double sqrt_2 = sqrt( 2.0 );

double dis( int x, int y )
{
return D[x + y] + d[x + y] - y * sqrt_2;
}

int main()
{
int N;
scanf( "%d", &N );
for( int i = 1, k = 1, j = 1; i < 10005; ++i )
{
d[i] = sqrt( ( double ) k ) + d[i-1];
D[i] = i * sqrt_2 + D[i-1];
k += 4 * i;
}
while( N-- )
{
int x1, y1, x2, y2;
scanf( "%d %d %d %d", &x1, &y1, &x2, &y2 );
printf( "%.3lf\n", fabs( dis( x2, y2 ) - dis( x1, y1 ) ) );
}
return 0;
}

相关文章:

  • 2022-12-23
  • 2021-06-23
  • 2022-01-07
  • 2021-11-02
  • 2021-08-29
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
猜你喜欢
  • 2021-04-05
  • 2022-12-23
  • 2022-03-07
  • 2021-06-06
  • 2021-09-01
相关资源
相似解决方案