1 条题解

  • 0
    @ 2024-5-10 0:45:58

    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;
    }
    

    Pascal :

    var a,b,x1,x2,y1,y2:longint;s:real;
    begin
     readln(a,b);
     while not eof do
      begin
      readln(x1,y1,x2,y2);
      s:=s+sqrt(sqr(x1-x2)+sqr(y1-y2))/1000;
      end;
     s:=s/10;
     if (s<10)and(s>1) then
      if frac(s)*60>=10 then
       writeln('0',trunc(s),':',frac(s)*60:0:0)else
       writeln('0',trunc(s),':0',frac(s)*60:0:0)
     else if s>10 then
      if frac(s)*60>=10 then
       writeln(trunc(s),':',frac(s)*60:0:0)else
       writeln(trunc(s),':0',frac(s)*60:0:0)else
      if s*60>=10 then
       writeln('00:',s*60:0:0)else
       writeln('00:0',s*60:0:0)
    end.
    

    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
    6222
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者