C. Fly time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n−2n−2 intermediate planet…
本题应该是可以使用实数二分的,不过笔者一直未调出来,而且发现了一种更为优美的解法,那就是逆推. 首先,不难猜到在最优解中当飞船回到 111 号节点时油量一定为 000, 这就意味着减少的油量等于减少之前的油量,即 fuel=mb1−1fuel=\frac{m}{b_{1}-1}fuel=b1​−1m​ 我们还可以将起飞和降落视为同一种操作,将公式进行变换,就得到 : fuel′=ai∗fuel+mai−1fuel'=\frac{a_{i}*fuel+m}{a_{i}-1}fuel′=ai​−1a…
题目 http://codeforces.com/contest/1011/problem/C Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n−2n−2 intermediate planets. Formally: we number all the planets from 11 to nn. 11 is Earth, n…
Codeforces Round #499 (Div. 1) https://codeforces.com/contest/1010 为啥我\(\rm Div.1\)能\(A4\)题还是\(\rm specialist....\) A. Fly 二分答案,送分题. #include<bits/stdc++.h> using namespace std; void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch…
Codeforces Round #499 (Div. 2) https://codeforces.com/contest/1011 A #include <bits/stdc++.h> using namespace std; ]; string s; int main(){ ; sort(a,a+n); ,p=-;i<n&&j<k;i++){ <a[i])r+=a[i],j++,p=a[i]; } cout<<(j==k?r:-); } B #…
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B.Rocket 极其简单的一道交互题,有些位置会说反的,那么就选一个数来询问直接选出所有的这样的位置 显然,选择\(\rm 1\)和\(\rm m\)都可以,选择完之后直接二分就行了 代码: #include<cstdio> #include<iostream> #include<…
Codeforces Round #499 (Div. 1) F. Tree 题目链接 \(\rm CodeForces\):https://codeforces.com/contest/1010/problem/F Solution 设\(v_i\)表示第\(i\)个点的果子数,设\(b_i=v_i-\sum_{x\in son}v_x\),显然依题意要满足\(b_i\geqslant 0\). 根据差分的性质我们可以得到\(\sum b_i=x\). 假设我们硬点树上剩下了\(m\)个点,则…
C. Fly 链接:http://codeforces.com/group/1EzrFFyOc0/contest/1011/problem/C 题型:binary search .math. 题意:总共有n个星球,飞船从地球起飞经过n-2个星球(在每个星球上做降落.起飞的动作)到达火星,在火星上同样降落起飞,然后直接返回地球做降落.每个星球起飞所需的燃料质量为ai,降落所需要的燃料质量为bi.飞船本身载重为m,附加燃料质量为所求值.问至少需要多少质量的燃料使得地球能做完整的往返运动,精度为1e-…
题目: http://codeforces.com/contest/1011/problem/D This is an interactive problem. Natasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find som…
D. Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the…