原题链接

题目大意: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. POJ 1503 Integer Inquiry 大数 难度:0

    题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util. ...

  2. jsp:useBean标准动作

    1.bean法则 JavaBean和企业JavaBean是完全不相干的两个东西.普通的非企业JavaBean需要满足一定的规范才能被JSP和servlet使用: 1)必须有一个无参数的公共构造函数: ...

  3. Servlet初识

    1.servlet的生命周期 servlet生命周期中的三大重要时刻 servlet从不存在状态迁移到初始化状态(能够为客户提供服务),首先是从构造函数开始,但是构造函数只是使其成为一个对象,而不是一 ...

  4. php操作文件(读取写入文件)

    一,PHP如何读取文件 PHP读取文件可以读取当前服务器或远程服务器中的文件.其步骤是:打开文件.读文件和关闭文件. 1,PHP如何打开文件 使用PHP函数fopen()打开一个文件,fopen()一 ...

  5. mybatis分页插件PageHelper的使用(转)

    Mybatis 的分页插件PageHelper-4.1.1的使用 Mybatis 的分页插件 PageHelper 项目地址:http://git.oschina.net/free/Mybatis_P ...

  6. SharePoint安全 - 攻破SharePoint(黑客工具介绍)

    博客地址 http://blog.csdn.net/foxdave SharePoint的安全性很高,这是我们潜意识里的第一印象,所以具体的安全性体现在哪并没仔细研究过.但是事实上确实没有绝对安全的东 ...

  7. (转)ASP.NET(C#) 读取EXCEL ——另加解决日期问题

    使用OLEDB可以对excel文件进行读取,我们只要把该excel文件作为数据源即可. 一 在D盘创建excel文件test.xls: 二 将工作表Sheet1的内容读取到DataSet string ...

  8. 安全增强 Linux (SELinux) 剖析

    架构和实现 Linux® 一直被认为是最安全的操作系统之一,但是通过引入安全增强 Linux(Security-Enhanced Linux,SELinux),National Security Ag ...

  9. iOS开发之瞬间位移动画效果

    步骤:1.使用single view application 创建一个新的项目 2.在.h文件中遵守<UIGestureRecognizerDelegate>协议,创建一个UIimagev ...

  10. BZOJ 3165 Segment

    同上题. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm&g ...