天天看點

hdu 2001 - 計算兩點間的距離位址定位分析代碼性能

位址

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

定位

  • 數學題
  • 水題

分析

  • (x2−x1)2+(y2−y1)2−−−−−−−−−−−−−−−−−−√

代碼

[cpp]

view plain copy print ?

  1. #include <iostream>  
  2. #include <math.h>  
  3. #include <stdio.h>  
  4. #include <string.h>  
  5. using namespace std;  
  6. int main() {  
  7.     double x1,y1,x2,y2;  
  8.     while(scanf(“%lf %lf %lf %lf”,&x1,&y1,&x2,&y2)!=EOF) {  
  9.         double tmp=pow(x2-x1,2)+pow(y2-y1,2);  
  10.         tmp=sqrt(tmp);  
  11.         printf(”%.2lf\n”,tmp);  
  12.     }  
  13.     return 0;  
  14. }  

性能

Exe.Time Exe.Memory Code Length Language
15MS 1880K 334B c++
上一篇: 街景随拍
下一篇: 中環街景