当前位置:网站首页>CF591A Wizards‘ Duel
CF591A Wizards‘ Duel
2022-07-19 16:43:00 【༺Blog༒Hacker༻】
Personal profile
Hello everyone , I am a 2022 year 3 Ranked third in the rookie list in January ༺Blog༒Hacker༻
Stand by me : give the thumbs-up + Collection ️+ Leaving a message.
Maxim :༺ Always do high quality ༒programmer༻
Series column :CF & UVA
Personal home page :༺Blog༒Hacker༻️

notes ( Please refer to CF665B Shopping):
️ my Update time It's going to change , monthly 2-5 piece , Thank you for your long-term support !
CF591A Wizards’ Duel
️ Title Description
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.
🧡 Input format
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.
Output format
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 .
.
Title Translation
Title Description
Harry Potter and Voldemort fought again . This time their location is a length of l l l At both ends of the corridor . Two people simultaneously fired a fatal spell at each other . We now know that the pulse speed of Harry's spell is p p p Meters per second , And Voldemort's spell speed q q q Meters per second .
Two spells are crossing the corridor , Rush to each other . At the moment of collision , They turned around at full speed and flew towards the person who launched them . after , Once it rushes back to its launcher , The wizard will bounce it back at the original speed .
Because Harry has completely mastered the basic knowledge of magic , He knew that when the two spells collided for the second time , Both spells will disappear , And there will be a powerful explosion there . however , The little wizard is not good at mathematics , So he asks you to help him calculate the distance from his position to the second collision position of the two spells . Suppose two opponents do not change their positions during the whole battle .
Input format
Enter an integer in the first line l ( 1 < = l < = 1000 ) —— l (1<=l<=1000 )—— l(1<=l<=1000)—— Corridor length
Enter a positive integer on the second line p p p , On the third line, enter a positive integer q —— q —— q—— They represent the flying speed of Harry Potter and Voldemort's magic respectively .
Output format
Output a positive number —— —— —— The distance from the location of Harry Potter to the location of the second collision of the two spells .
🤎 I/o sample
Input #1
100
50
50
Output #1
50
Input #2
199
60
40
Output #2
119.4
explain / Tips
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;
}

Thank you for your long-term support , Like collection is my motivation to update , See you next time , Bye-bye !!!

边栏推荐
- Zhang Chaoyang runs 33km at night: live chat on physics reveals the cause of "super moon"
- torch dist分布式数据汇总
- Want to self-study software testing? Ruthless ridicule.
- Complete size comparison with bit operation
- Torch dist distributed data aggregation
- Is it safe to open citic securities account by mobile phone?
- 【Unity3D】UGUI之InputField
- 如何下载ScienceDirect(Elsevier)文献的补充材料
- Nacos注册表是怎么解决读写并发冲突的
- Nacos Client常用配置
猜你喜欢

RT-thread培训学习和心得(二)

Spichi rushes to the scientific innovation board: annual revenue of 300million and loss of 340million. Alibaba and Lenovo star are shareholders

Yolov7: how to export the correct onnx based on your own training model

CF591A Wizards‘ Duel

OS知识点简介(一)

熵基科技通过注册:年营收19.55亿 应收账款账面余额2.9亿

Thesis reading_ Medical NLP_ SMedBERT

Aspose. OCR 22.6 for . NET//Aspose. OCR

关于在使用ssh命令远程执行命令中有转义字符的问题

System information function of MySQL function summary
随机推荐
JMeter 21 天打卡 day10
OS知识点简介(二)
CF591A Wizards‘ Duel
后缀表达式(DAY 65)
07. Advanced application of binary tree
软件设计师:12-案例分析例题
Thesis reading_ Medical NLP_ SMedBERT
Summary of general test points for file upload
Date and time function of MySQL function summary
劲旅环境深交所上市:市值50亿 于晓霞家族色彩浓厚
云服务ECS/RDS:搭建云服务器ECS管理linux,搭建云数据库管理创建RDS MySQL;
epoll相关函数和结构介绍以及服务器开发流程
为什么很多人都知道打工不挣钱却还在打工?
1805. 字符串中不同整数的数目 ●
JMeter 21 day clock in Day12
MySQL 正則錶達式
flask 视图
array.groupBy,对数组进行分类
Torch dist distributed data aggregation
Condition judgment function of MySQL function summary