ZOJ 1105 FatMouse’s Tour
题目大意: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的更多相关文章
- ZOJ 2109 FatMouse' Trade (背包 dp + 贪婪)
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat ...
- zoj 1108 FatMouse's Speed 基础dp
FatMouse's Speed Time Limit: 2 Seconds Memory Limit:65536 KB Special Judge FatMouse believe ...
- zoj 1108 FatMouse's Speed 基础dp
FatMouse's Speed Time Limit: 2 Seconds Memory Limit:65536 KB Special Judge FatMouse believe ...
- zoj 2109 FatMouse' Trade
FatMouse' Trade Time Limit: 2 Seconds Memory Limit: 65536 KB FatMouse prepared M pounds of cat ...
- 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 ...
- ZOJ 1107 FatMouse and Cheese
原题链接 题目大意:FM在一个街道n*n街道的(0,0)点,在每个网格里放着cheese,他要尽可能多的吃这些cheese.有两个规则:1)他跑的总距离不能超过k步:2)下一个节点的cheese的块数 ...
- zoj 1107 FatMouse and Cheese(记忆化搜索)
题目链接:点击链接 题目大意:老鼠从(0,0)出发,每次在同一个方向上最多前进k步,且每次到达的位置上的数字都要比上一个位置上的数字大,求老鼠经过的位置上的数字的和的最大值 #include<s ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
随机推荐
- myeclipse9.x,10.x 安装时出现pulse-one-64,failed to load the JNI shared library
- NOIP2005 篝火晚会 解题报告
佳佳刚进高中,在军训的时候,由于佳佳吃苦耐劳,很快得到了教官的赏识,成为了“小教官”.在军训结束的那天晚上,佳佳被命令组织同学们进行篝火晚会.一共有n个同学,编号从1到n.一开始,同学们按照1,2,… ...
- 在linux终端下打开pdf文件
已经使用linux有很长的时间了,感觉linux的终端使用起来非常的方便.但是怎么在linux下用命令的方式打开pdf文件呢.我查了一下,打开pdf的命令是: evince [filename] 例如 ...
- swing LayoutManager 和多态
interface LayoutManager{ void show();}class FlowLayout implements LayoutManager{ public void show(){ ...
- What am I missing out in life if I don't have a girlfriend?
http://www.quora.com/What-am-I-missing-out-in-life-if-I-dont-have-a-girlfriend/answer/Kelly-Erickson ...
- pager分页框架体会
<pg:pager> 元素的属性中: maxPageItems说的是每页偏移量是多少,这个并不是说每一页显示多少,而是第二页比第一页来说,在第一页的尾部增加多少,第一页又被覆盖多少,是决定 ...
- <矩阵的基本操作:矩阵相加,矩阵相乘,矩阵转置>
//矩阵的基本操作:矩阵相加,矩阵相乘,矩阵转置 #include<stdio.h> #include<stdlib.h> #define M 2 #define N 3 #d ...
- 一篇文章教你学会基础的HTML
html是学习做网页的基础,漂亮的网页与布局就是由有些html代码组成,大家看完这篇文章就可以简单的了解html了,多写多练 如果你不致力于成为美工的话,那么作为开发人员,可以读懂HTML.必 ...
- stm32启动文件 startup_stm32f10x_hd.s
;* 文件名 : startup_stm32f10x_hd.s;* 库版本 : V3.5.0;* 说明: 此文件为STM32F10x高密度 ...
- PHP+MySql字符问题原理分析
假如数据库已经设置了utf-8 ,php文件也设置了utf-8 ,但在php文件的查询语句中未添加了 mysql_query("set names utf8")语句,此时php页面 ...