原题链接

题目大意:FM要去逛街,他可以走任何街道,在任何路口转弯。他走一条陌生街道的速度是20公里每小时,走一条熟悉街道的速度是50公里每小时。输入是街道信息,输出消耗时间。

解法:本质就是浮点运算,求两点间距离。

参考代码:

#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std; int main(){
int x0,y0,x1,x2,y1,y2,time;
double dist=0.0,d;
string str;
char *p; while(cin>>x0>>y0){ //x0,y0 is useless, but still need to be read in
cin.get();
dist=0.0;
while(getline(cin,str)&&str!="java"){
p=&str[0]; //change a string to a char point!!!
sscanf(p,"%d%d%d%d",&x1,&y1,&x2,&y2);
d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
dist+=sqrt(d);
}
dist=dist*2/1000.0/20.0*60.0;
time=int(dist+0.5); //convert double to int
cout<<time/60<<':';
if(time%60<10)cout<<'0'<<time%60<<endl;
else cout<<time%60<<endl;
} return 0;
}

ZOJ 1105 FatMouse’s Tour的更多相关文章

  1. ZOJ 2109 FatMouse&#39; Trade (背包 dp + 贪婪)

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat ...

  2. zoj 1108 FatMouse's Speed 基础dp

    FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge FatMouse believe ...

  3. zoj 1108 FatMouse's Speed 基础dp

    FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge FatMouse believe ...

  4. zoj 2109 FatMouse' Trade

    FatMouse' Trade Time Limit: 2 Seconds      Memory Limit: 65536 KB FatMouse prepared M pounds of cat ...

  5. ZOJ 1108 FatMouse's Speed (HDU 1160) DP

    传送门: ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=108 HDU :http://acm.hdu.edu.cn/s ...

  6. ZOJ 1107 FatMouse and Cheese

    原题链接 题目大意:FM在一个街道n*n街道的(0,0)点,在每个网格里放着cheese,他要尽可能多的吃这些cheese.有两个规则:1)他跑的总距离不能超过k步:2)下一个节点的cheese的块数 ...

  7. zoj 1107 FatMouse and Cheese(记忆化搜索)

    题目链接:点击链接 题目大意:老鼠从(0,0)出发,每次在同一个方向上最多前进k步,且每次到达的位置上的数字都要比上一个位置上的数字大,求老鼠经过的位置上的数字的和的最大值 #include<s ...

  8. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  9. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

随机推荐

  1. 用for循环打印菱形

    package nothh; public class mmm { public static void main(String[] args) { //for循环内的 for按顺序运算,先打印1/4 ...

  2. undefined reference to typeinfo - C++ error message

    undefined reference to typeinfo - C++ error message There are some compiler and loader error message ...

  3. 计算C++类所占用的字节(即sizeof)

    在类中,如果什么都没有,则类占用1个字节,一旦类中有其他的占用空间成员,则这1个字节就不在计算之内,如一个类只有一个int则占用4字节而不是5字节.如果只有成员函数,则还是只占用1个字节,因为类函数不 ...

  4. windows操作系统日常使用

    快捷键使用: 看实例,学经验,我看行. 1.人体学输入设备被禁用怎么办(鼠标被禁用.键盘被禁用) 有一天脑子抽风,把鼠标给禁用了.以前不常用快捷键,这下必须学学怎么使用快捷键了,现在记下来,防止以后脑 ...

  5. URL动态赋值

    url动态赋值: 指的是url中包含{selector},即花括号括起来的jQuery选择器,当提交该url时,框架会自动将selector对应元素的值替换到花括号所占区域. (感觉实现了一点类似el ...

  6. The authenticity of host 192.168.0.xxx can't be established.

    用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束 错误是:The authenticity of host 192.168.0.xxx can't b ...

  7. SharePoint 2013 Nintex Workflow 工作流帮助(六)

    博客地址 http://blog.csdn.net/foxdave 工作流动作 7. Call web service(Integration分组) 一个调用WebService的操作. 自然,配置项 ...

  8. pyqt5 笔记(二)实现http请求发送

    上个图~ index.py 文件 # -*- coding: utf-8 -*- from PyQt5 import QtWidgets,QtCore #从pyqt库导入QtWindget通用窗口类 ...

  9. iframe和form表单的target应用简单例子

    iframe和form表单的target属性   Problem: 刷新主页面中的其中一个iframe,其他内容不变 Solution: main.jsp <body onload=" ...

  10. java读取大容量excel之二(空格、空值问题)

    最近在项目中发现,对于Excel2007(底层根本是xml) ,使用<java读取大容量excel之一>中的方式读取,若待读取的excel2007文件中某一列是空值,(注意,所谓的空值是什 ...