POJ Challenge Round 5 -- A:magic (物理)
来源:互联网 发布:那英人品知乎 编辑:程序博客网 时间:2024/06/07 14:04
A:magic
- 总时间限制:
- 1000ms
- 内存限制:
- 131072kB
- 描述
魔法师Silly Hook正在表演一个神奇的魔术,他变出了他自己的N个分身,并成正N边形分布,他本身处于这个正N边形的中心,正N边形的边长为A。然后,每个分身都会朝顺时针方向下一个分身以一个相同的固定的速度V移动,移动方向会随着下一个分身的位置变化而变化,最终所有分身都将到达正N边形的中心,也就是回到Silly Hook本身,表演结束。
Silly Hook计划在比利时埃诺省Silly市巡回演出,他想提前知道对于每次表演需要多少时间。
- 输入
- 多组数据,到EOF结束。
每组数据一行三个整数N,A,V,分别表示 每次表演的分身个数,分身分布的正N边形的边长,每个分身移动的速度。
N ≤ 300 , A ≤ 400000 , V ≤ 10000 , 答案 ≤ 10000000 , 数据组数 ≤ 10 - 输出
- 每组数据一个实数,表示最后一个分身到达本身的时间,保留小数点后5位。
- 样例输入
3 10 54 20 8
- 样例输出
1.333332.50000
思路:把每一个分身抽象为一个点,取其中两个点A,B(A始终朝向B),则对B的速度v做正交分解,取其中一个与正多边形的边平行的速度,这样可以转化为一个简单的追及问题,而B另外一个分解的速度则不影响答案,它只影响偏转速度。
AC代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;const double PI = 4.0 * atan(1.0);int N, A, V;int main() {while(cin >> N >> A >> V) {double du = PI * (N - 2) / N;double ans = A * 1.0 / (V * 1.0 + cos(du) * V);printf("%.5lf\n", ans);}return 0;}
1 0
- POJ Challenge Round 5 -- A:magic (物理)
- Codeforces Round #335 606A - Magic Spheres
- POJ挑战赛3(POJ Challenge Round 3)题解
- Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) -- A. Broken Clock (贪心)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) -- A. Checking the Calendar(思路)
- CF-Tinkoff Challenge-Elimination Round-A-Oleg and shares
- Google Code Jam 2014 Qualification Round:Problem A. Magic Trick
- Codeforces Round #189 (Div. 2)---A. Magic Numbers
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
- Codeforces Round #335 (Div. 2) A.Magic Spheres
- Codeforces Round #335 (Div. 2) A. Magic Spheres
- A Magic Lamp(RMQ)
- POJ 3530 A Modular Arithmetic Challenge 英文少
- Codeforces Round Intel Code Challenge Final Round A.Checking the Calendar
- POJ 1584:A Round Peg in a Ground Hole _判断点是否在多边形内(5种方法)
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)【A,B,C,D】
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A题
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)A. Checking the Calendar
- 沙龙邮箱助手
- 用C语言爬网页代码
- CodeForces 519D A and B and Interesting Substrings
- uva难度分级列表
- CSS和js自动添加版本号
- POJ Challenge Round 5 -- A:magic (物理)
- 第5题作业
- 一张图看懂Android注册登录+服务端
- BZOJ 1216 HNOI 2003 操作系统 堆
- 第三题(对象的序列化)
- JFinal源码走读_5_Validator校验源码分析
- jquery中使用append添加html导致onclick事件失效
- 运行时类型信息RTTI
- the item width must be less than the width of the UICollectionView minus the section insets left and