1 条题解
-
0
C :
#include<stdio.h> #include<math.h> int main() { double x1,y1,x2,y2,s=0,t; int m; scanf("%*d%*d"); while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF) s+=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); t=s/20000*2; m=(t-(int)t)*60+0.5; if(m==60) printf("%02d:00\n",(int)t+1); else printf("%02d:%02d\n",(int)t,m); return 0; }
C++ :
#include<stdio.h> #include<math.h> int main() { double x1,y1,x2,y2,s=0,t; int m; scanf("%*d%*d"); while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF) s+=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); t=s/20000*2; m=(t-(int)t)*60+0.5; if(m==60) printf("%02d:00\n",(int)t+1); else printf("%02d:%02d\n",(int)t,m); return 0; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x = in.nextInt(); int y = in.nextInt(); double sum = 0; while (in.hasNextInt()) { int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); sum += Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)); } double time = sum * 2 / 20000; int hour = (int) sum * 2 / 20000; int minutes = (int) ((time - hour) * 60 + 0.5); String strHour = null, strMinutes = null; if (hour < 10) strHour = "0" + hour; else strHour = "" + hour; if (minutes < 10) strMinutes = "0" + minutes; else strMinutes = "" + minutes; System.out.printf(strHour + ":" + strMinutes); } }
- 1
信息
- ID
- 1323
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者