zoj1105

FatMouse's Tour
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu
Appoint description: 

Description

As the Chairman of Association of Campus Mice (ACM), FatMouse is going out of his office to tour his kingdom. But with the International Cat Patrol Centers (ICPC) locating at every street, he has to carefully plan his trip so that it requires minimum time to visit everyone living at every street.

Assume that there are mice living at both sides of each street, yet FatMouse can only visit one side of a street in a single pass. He can turn any direction (including a U-turn) at any intersection, and can turn around at the end of any street. He goes at 20 km/h when visiting his people on the way (shaking hands and saying "hi"), and 50 km/h when passing a visited side of a street (since the cats must be awake by then).

Input Specification

The input file contains several test cases. Each test case starts from a line with two integers: the x,y coordinates of FatMouse's office (in metres). Up to 100 lines follow. Each gives the coordinates (in metres) of the beginning and end of a street. All streets are perfectly straight, with one side in each direction. It is possible to reach all streets from the office. Each test case is finished by a special word "java".

Output Specification

For each test case, your output should be one line with the time, in hours and minutes, required to tour the kingdom and return to the office. Round to the nearest minute.

Sample Input

0 0
0 0 10000 10000
5000 -10000 5000 10000
5000 10000 10000 10000
java

Output for Sample Input

3:55
#include<cstdio>
#include<cmath>



这道题目题意要阅读清楚。每一条路都会经过两次(一来一回)。但是每条路只会访问一次(以后再不会经过这条路了)。

注意sscanf的用法,之前都没有注意到可以这样用。
using namespace std;
double x[100],y[100];


double help(int n1,int n2)
{
    return sqrt((x[n1]-x[n2])*(x[n1]-x[n2])+(y[n1]-y[n2])*(y[n1]-y[n2]));


}
int main()
{


    while(scanf("%lf%lf",&x[0],&y[0])!=EOF)
    {
        char ss[1000];


        double  ans=0;
        getchar();
        while(gets(ss))
        {
            if(ss[0]=='j')
                break;
            sscanf(ss,"%lf%lf%lf%lf",&x[1],&y[1],&x[2],&y[2]);
            ans+=help(1,2);




        }
        ans=ans*60*2/20000;
        int an2=floor(ans+0.5);
        printf("%d:%02d\n",an2/60,an2%60);


    }


    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值