Codeforces Round #105 (Div. 2) B. Escape

Codeforces Round #694 (Div. 1 + Div2)(A ~ H,8题全,超高质量题解)【每日亿题】2021/2/1、2/2 寒假每日训练2021/1/21 每日亿题 这套Div2 好简单呀,我写了不到两个小时就快AK了… 阅读详情

B. Escape
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The princess is going to escape the dragon's cave, and she needs to plan it carefully.

The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.

The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off.

Input

The input data contains integers vp, vd, t, f and c, one per line (1 ≤ vp, vd ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000).

Output

Output the minimal number of bijous required for the escape to succeed.

Sample test(s)
Input
1
2
1
1
10
Output
2
Input
1
2
1
1
8
Output
1
Note

In the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.

The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou.


题目链接:http://codeforces.com/problemset/problem/148/B


题目大意:已知公主逃跑的速度vp和龙的速度vd,公主从龙穴逃跑 t 小时后龙发现并追赶公主,公主要到达距离龙穴 c 米处的目的C地才安全。在龙追赶公主的过程中,如果公主使用一颗钻石,那么该钻石能使龙返回到洞穴并在洞穴中停留 f 小时。求公主到达目的地最少使用多少颗钻石。


解题思路:过程模拟。在龙追上公主的一刻使用钻石。注意如果公主和龙同时到达目的地时不必再使用钻石。


代码如下:

#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int maxn=1005;
int main(void)
{
	double vp,vd,t,f,c,s;
	int ans=0;
	scanf("%lf%lf%lf%lf%lf",&vp,&vd,&t,&f,&c);
	if(vp>vd)
	{
		printf("0\n");
		return 0;
	}
	s=t*vp*vd/(vd-vp);   //龙第一次追上公主是距龙洞的距离
	while(s<c)           //如果追上但还没到达目的地
	{
		ans++;            //使用一颗钻石
		t=s/vd+f;         //龙返回洞穴和停留的时间
		s+=t*vp;          //这段时间后公主距龙洞的距离
		s=s*vd/(vd-vp);   //再次追上时的距龙洞的距离
	}	
	printf("%d\n",ans);
}


Android存储方案对比(SharedPreferences 、 MMKV 、 DataStore) 简介:本文介绍了Android开发中常用的键值对存储方案,包括SharedPreferences、MMKV和DataStore,并且对比了它们在性能、并发处理、易用性和稳定性上的特点。通过实际代码示例,帮助开发者根据项目需求选择最适合的存储方案,提升应用性能和用户体验。 阅读详情

相关推荐

第1部分 基础算法(提高篇)--第2章 二分与三分1439:【SCOI2010】传送带

1439:【SCOI2010】传送带 时间限制: 2000 ms 内存限制: 65536 KB 提交数: 372 通过数: 212 【题目描述】 在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段。两条传送带分别为线段AB和线段CD。lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R。现在lxhgww想从A点走到D点,他想知道最少需要走多长时间。 【输入】 输入数据第一行是4个整数,表示A和B的坐标,分别为Ax,Ay,Bx,By 第二行是4个整

zqhf123的博客 834

Codeforces B. Escape

题意:公主以vp的速度逃跑,龙以vd的速度去追赶,公主出发t时间后龙才出发,如果龙追上了公主,公主便使用个道具是龙以原速度回到出发点,并且f时间后才可以出发。公主与终点距离c,只要公主到达终点龙就追不上公主,问公主需要使用多少次道具。 思路:如果龙的速度小于公主的速度就永远追不上,只需要计算每次龙追上公主的时间即可。再将距离和终点比较。具体看代码。 #include&lt;cstdio&gt...

JTY的博客 376

uniapp+uniCloud实现微信小程序一键登录

(用户唯一标识),用户登录成功后,开发者服务器可以将openid和session_key保存,生成一个自定义登录态的token令牌响应给微信小程序,通过token可以查询openid和session_key,小程序下次请求只要携带着token就可以证明已经登录。这个API就是获取用户信息,每次请求都会弹出授权窗口(这个可能会不弹,这个要看你的版本,根据版本来定,不懂的可以留下评论),用户同意后会返回。到这里就可以实现微信一键登录了,快去试试吧,有问题可以在评论区留言,我看见会尽我知道的为你解答。

lb2917的博客 2576

水题 Codeforces Round #105 (Div. 2) B. Escape

题目传送门 1 /* 2 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 #include <cmath> 8 ...

weixin_34380781的博客 95

工业场景实战:基于YOLO与多格式标注的传送带异物检测数据集构建指南

本文详细介绍了基于YOLO与多格式标注的传送带异物检测数据集构建方法,涵盖数据采集、标注技巧(YOLO、COCO、VOC格式)、数据增强策略及实战案例。通过工业级解决方案,有效提升异物检测准确率与效率,适用于各类工业场景。

weixin_29168393的博客 463

Codeforces Round #632 (Div. 2) B.Kind Anton

Codeforces Round #632 (Div. 2) B.Kind Anton 题目链接 Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers a ...

旺崽的博客 2512

串行RapidIO(Serial RapidIO,SRIO):协议介绍

目录一、RapidIO背景介绍二、RapidIO协议概述2.1 包与控制符号2.2 包格式2.4 消息传递2.5 全局共享存储器2.6 流量控制2.7 串行物理层三、I/O逻辑操作与包格式四、维护操作与包格式五、消息操作与包格式六、总结 本文是基于Xilinx平台SRIO介绍(一)RapidIO协议介绍的内容作读书笔记。 一、RapidIO背景介绍 RapidIO采用三层分级体系结构,包括逻辑层、传输层和物理层该分级结的如下图所示: ● 逻辑层:位于最高层,定义全部协议和包的格式,它们为端点器件发起和完

Starry__的博客 1万+

Codeforces Round #619 (Div. 2) B.Motarack's Birthday

Codeforces Round #619 (Div. 2) B.Motarack’s Birthday Dark is going to attend Motarack’s birthday. Dark decided that the gift he is going to give to Motarack is an array a of n non-negative integers. D...

旺崽的博客 3107

C#WPF常用的9种布局方式详解

本文介绍WPF中常用的九种布局,Grid、StackPanel、WrapPanel、DockPanel、UniformGrid、Canvas、ScrollViewer、ViewBox、Border。

qq_30725967的博客 1万+

YOLO26 网络结构逐模块解析:Backbone/Neck/Head

本文解析了YOLO26目标检测网络的架构设计,重点介绍其在Backbone、Neck和Head三个核心组件的创新优化。Backbone采用改进的CSP模块与轻量级注意力机制,提升特征提取效率;Neck使用改进的BiFPN结构实现高效多尺度特征融合;Head采用完全解耦设计简化回归流程。文章详细分析了各模块的技术演进、实现细节和设计思想,通过流程图和代码示例展示了YOLO26的整体架构和关键组件实现。该研究对模型优化、定制开发和硬件部署具有重要指导意义。

一键难忘的博客 1241

Codeforces Round #614 (Div. 2) B.JOE is on TV!

Codeforces Round #614 (Div. 2) B.JOE is on TV! Our dear Cafe’s owner, JOE Miller, will soon take part in a new game TV-show “1 vs. n”! The game goes in rounds, where in each round the host asks JOE an...

旺崽的博客 3065

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Codeforces Round #306 (Div. 2)

题目传送:Codeforces Round #306 (Div. 2) 这次打的很差,有点累,先贴个代码吧。。 A - Two Substrings #include #include #include #include #include #include #include #include #include #include #include #i

Never say never 848

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

【codeforces】Codeforces Round #277 (Div. 2) 题解

传送门:Codeforces Round #277 (Div. 2)

poursoul 1411

Codeforces Round #687(Div2)A~D题题解

A. Prison Break 题目传送门: A. Prison Break 题目大意: 有一个n*m的监狱,每一个格子有一个犯人,坐标为( r , c )的格子有一条逃生通道,犯人每一秒可以向相邻的一个格子移动,问所有犯人到达逃生通道最久需要多少秒。 思路: 判断监狱四个角上的犯人到达逃生通道的时间即可 AC Code #include<bits/stdc++.h> using namespace std; int main() { int t; scanf("%d",&amp

稚始稚终的博客 2692

Codeforces Round #696 (Div. 2)(A~D题解)

Codeforces Round #696 (Div. 2)(A~C题解) ——南昌理工学院ACM集训队 题目链接:https://codeforces.ml/contest/1474 A. Puzzle From the Future In the 2022 year, Mike found two binary integers a and b of length n (both of them are written only by digits 0 and 1) that can have lead

jiushu_LQ的博客 3538

Codeforces Round #706 (Div. 2)-B. Max and Mex-题解

目录Codeforces Round #706 (Div. 2)-B. Max and MexProblem DescriptionInputOutputSample InputSample OnputNote题目大意题目分析MEX≥\ge≥n其实就是MEX=nMEX≤\le≤n解题思路AC代码 Codeforces Round #706 (Div. 2)-B. Max and Mex 传送门 Time Limit: 1 second Memory Limit: 256 megabytes Problem

<font color="Pink">Tisfy的博客</font> 1万+

Codeforces Round #532 (Div. 2)

Contests 链接:Codeforces Round #532 (Div. 2) A. Roman and Browser 题意 RomanRomanRoman 最开始打开了 nnn 个网页,所有网页要么是个测试网页,要么是一个社交网页,现在他打算每隔 kkk 个网页就关闭一个网页,要使得这两种网页的差的绝对值最大,求最大值。 输入 第一行为两个整数 n,k&amp;amp;nbsp;(2≤k&amp;amp;amp;...

Dmaxiya 1227

Codeforces Round #713 (Div. 3)-C. A-B Palindrome-题解

目录Codeforces Round #713 (Div. 3)-C. A-B PalindromeProblem DescriptionInputOutputSample InputSample Onput题目大意解题思路AC代码 Codeforces Round #713 (Div. 3)-C. A-B Palindrome 传送门 Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description You are given a

<font color="Pink">Tisfy的博客</font> 1万+

Codeforces Round #612 (Div. 2)

Codeforces Round #612 (Div. 2) B题: 题意:一横排是一张牌,如果满足任意三张牌可以组成的每一列有三张相同的牌或者有三张不同的牌就可以组成一副牌,问能组成多少副这样的牌,打乱顺序算一副。 题解:我们通过两张牌来匹配第三章牌的方式来确定。 #include<bits/stdc++.h> using namespace std; const int N=1e3...

行走天涯的豆沙包的博客 722

Codeforces Round #604 (Div.2)

Codeforces Round #604 (Div.2) 2019/12/5 22:35——2019/12/6 00:35 这是我经历了多次掉分之后的第一次上分,是个好兆头。虽然只有区区16分,但是见到情况有些好转,看到这么多天的努力没有白费,心里感觉还是很开心呢。 Codeforces Round #604 (Div.2) A. Beautiful String time ...

qq_30445397的博客 663

Codeforces Round #707 (Div. 2)

比赛传送门: Codeforces Round #707 (Div. 2) A. Alexey and Train 思路: 按题意模拟即可 AC Code #include<bits/stdc++.h> using namespace std; int a[105],b[105],t[105]; int main() { int d; scanf("%d",&d); while(d--) { int n; scanf("%d",&n); for(int i=1

稚始稚终的博客 1408

Codeforces Round #638 (Div. 2) C.Phoenix and Distribution

Codeforces Round #638 (Div. 2) C.Phoenix and Distribution 题目链接 Phoenix has a string s consisting of lowercase Latin letters. He wants to distribute all the letters of his string into k non-empty strin...

旺崽的博客 2704

【 Codeforces Round #596 [Div. 2] D. Power Products】

【 Codeforces Round #596 [Div. 2] D. Power Products】 Description You are given n positive integers a1,…,an, and an integer k≥2. Count the number of pairs i,j such that 1≤i<j≤n, and there exists an i...

来日浅谈的博客 2312
上一篇: ZOJ 3813 Pretty Poem (暴力)
下一篇: UVA onlinejudge 11401 - Triangle Counting
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值