当前位置:网站首页>CF591A Wizards‘ Duel
CF591A Wizards‘ Duel
2022-07-18 02:15:00 【༺Blog༒Hacker༻】
个人简介
大家好,我是2022年3月份新人榜排名第三的 ༺Blog༒Hacker༻
支持我:点赞+收藏️+留言
格言:༺永做优质༒programmer༻
系列专栏:CF & UVA
个人主页:༺Blog༒Hacker༻️

注(具体请见CF665B Shopping):
️我的更新时间会有所改变,每月2-5篇,感谢各位长期以来的支持!
CF591A Wizards’ Duel
️题目描述
Harry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length l l l . Two opponents simultaneously charge a deadly spell in the enemy. We know that the impulse of Harry’s magic spell flies at a speed of p p p meters per second, and the impulse of You-Know-Who’s magic spell flies at a speed of q q q meters per second.
The impulses are moving through the corridor toward each other, and at the time of the collision they turn round and fly back to those who cast them without changing their original speeds. Then, as soon as the impulse gets back to it’s caster, the wizard reflects it and sends again towards the enemy, without changing the original speed of the impulse.
Since Harry has perfectly mastered the basics of magic, he knows that after the second collision both impulses will disappear, and a powerful explosion will occur exactly in the place of their collision. However, the young wizard isn’t good at math, so he asks you to calculate the distance from his position to the place of the second meeting of the spell impulses, provided that the opponents do not change positions during the whole fight.
🧡输入格式
The first line of the input contains a single integer l ( 1 < = l < = 1000 ) — l ( 1<=l<=1000 ) — l(1<=l<=1000)— the length of the corridor where the fight takes place.
The second line contains integer pp , the third line contains integer q ( 1 < = p , q < = 500 ) — q ( 1<=p,q<=500) — q(1<=p,q<=500)— the speeds of magical impulses for Harry Potter and He-Who-Must-Not-Be-Named, respectively.
输出格式
Print a single real number — — — the distance from the end of the corridor, where Harry is located, to the place of the second meeting of the spell impulses. Your answer will be considered correct if its absolute or relative error will not exceed 1 0 − 4 10^{-4} 10−4.
.
Namely: let’s assume that your answer equals a a a , and the answer of the jury is b b b . The checker program will consider your answer correct if .
.
题意翻译
题目描述
哈利波特与伏地魔再次进行了斗争。这次他们所在的地点是一个长度为 l l l 的走廊的两端。两个人同时向对方发射了一个致命的咒语。我们现在知道哈利的咒语的脉冲速度为 p p p 米每秒,而伏地魔的咒语速度 q q q 米每秒。
两个咒语正穿越走廊,冲向对方。在碰撞的那一刻,它们以原速掉头朝发射它们的人飞去。之后,一旦它冲回它的发射者,那个巫师就会将它以原速反弹回去。
因为哈利已经完全掌握了魔法的基础知识,他知道在两个咒语第二次碰撞时,两个咒语都会消失,并且会有一个强有力的爆炸在那儿发生。但是,小巫师并不擅长数学,因此他请求你帮他计算从他的位置到两个咒语第二次碰撞位置的距离。假设两个对手在整个战斗过程中没有改变位置。
输入格式
第一行输入一个整数 l ( 1 < = l < = 1000 ) —— l (1<=l<=1000 )—— l(1<=l<=1000)——走廊长度
第二行输入正整数 p p p ,第三行输入正整数 q —— q —— q——分别代表哈利波特与伏地魔施展的魔法的飞行速度。
输出格式
输出一个正数 —— —— ——从哈利波特的位置到两个咒语第二次碰撞位置的距离。
🤎输入输出样例
输入 #1
100
50
50
输出 #1
50
输入 #2
199
60
40
输出 #2
119.4
说明/提示
In the first sample the speeds of the impulses are equal, so both of their meetings occur exactly in the middle of the corridor.
CODE
#include<bits/stdc++.h>
#define ll long long
#define MAXN 1005
using namespace std;
ll n,m,a[MAXN],ans;
bool cmp(int x,int y)
{
return x>y;
}
signed main()
{
cin>>n>>m;
for(int i=1;i<=n;++i)
{
cin>>a[i];
sort(a+1,a+1+n,cmp);
}
for(int i=1;i<=n;++i)
{
m-=a[i];
ans++;
if(m<=0)
break;
}
cout<<ans<<endl;
return 0;
}

感谢各位长期以来的支持,点赞收藏是我更新的动力,下期再见,拜拜!!!

边栏推荐
- 奥扬科技IPO被终止注册:年营收8亿 苏伟持有67.5%股权
- 手机开通中信证券账户安全吗?
- JMeter 21 天打卡 day08
- Is it free to open an account online with flush software for stock speculation? Is it safe to open an account?
- 同花顺软件线上开户免费吗?开户安全吗?
- Using deep learning to make robot brain drawings
- 后缀表达式(DAY 65)
- Handwritten simple promise code comments
- LeetCode 300:最长递增子序列
- 03. Dichotomy, complexity, dynamic array, hash table and ordered table
猜你喜欢

Ch549/ch548 learning notes 7 - USB device initialization

flex 布局 justify-content:space-between 最后一行左对齐的解决方案

JVM性能调优方式
![LeetCode 565 数组嵌套[dfs 记忆化] HERODING的LeetCode之路](/img/d3/1d0f6668d9543136c729153bdebff0.png)
LeetCode 565 数组嵌套[dfs 记忆化] HERODING的LeetCode之路

【foobar 2000】如何在手机、电脑上播放局域网内另一台电脑上存储的音乐?FTP服务器、UPnP/DLNA协议、构建Music server、创建音乐服务器

第 4 章:崭露头角,基于Cglib实现含构造函数的类实例化策略
![[立创&传智&黑马程序员&CSDN]训练营——仿生机械狗](/img/31/73f0eb570e10cfc4421f075f2a1b9c.jpg)
[立创&传智&黑马程序员&CSDN]训练营——仿生机械狗

The read image of OpenCV notes is de distorted and saved as a new image

总结阅读器与直播的奇怪交互:复习双迪技术

熵基科技通过注册:年营收19.55亿 应收账款账面余额2.9亿
随机推荐
Deep learning environment configuration tensorflow2+keras
Ch549/ch548 study notes 4 - timer
后缀表达式(DAY 65)
Ugui source code analysis - clipperregistry
Using deep learning to make robot brain drawings
Csgo suddenly returns to the desktop, and other applications are unresponsive. How can we not restart and close it
自定义MVC 框架
Openresty Lua resty lrucache cache
Object memory layout and synchronized lock upgrade
4273. 链表合并(DAY 64)
软件测试培训不靠谱?花费3W学软件测试半年没找到工作?
How is flush software stock online free?? Is it safe to open an account?
CSDN认证C1级别学习笔记 - Web进阶篇
Ugui source code analysis - rectmask2d
03. Dichotomy, complexity, dynamic array, hash table and ordered table
Entropy technology passed the registration: the annual revenue was 1.955 billion, and the book balance of accounts receivable was 290million
用位运算完成大小比较
思必驰冲刺科创板:年营收3亿亏3.4亿 阿里与联想之星是股东
Ch549/ch548 learning notes 9 - USB device endpoint processing
Which securities company is the account given by Yixue school? Is it safe to open an account