zoukankan      html  css  js  c++  java
  • SPOJ HAMSTER1

    题目链接http://www.spoj.com/problems/HAMSTER1/

    题目大意:理想情况下斜抛运动初速度V0,自由落体加速度g = 10m/s,最大高度H,水平距离X,给定K1,K2问K1 * X + K2 * H最大值。

    解题思路:化简+辅助角公式直接计算得到结果就行。。话说tag里面有二分搞毛?

    代码:

     1 const double PI = acos(-1);
     2 int v0, k1, k2;
     3 int g = 10;
     4 
     5 void solve(){
     6     if(k2 == 0){
     7         printf("%.3f %.3f
    ", PI / 4, k1 * v0 * v0 / (double) g);
     8         return;
     9     }
    10     else if(k1 == 0){
    11         printf("%.3f %.3f
    ", PI / 2, 0.5 * v0 * v0 * k2 / (double) g);
    12         return;
    13     }
    14     double phi = atan(-k2 / (4.0 * k1));
    15     double ans1 = PI / 2.0 - phi;
    16     ans1 /= 2;
    17     double ans2 = v0 * v0 * (2 * k1 * sin(2 * ans1) - k2 / 2.0 * cos(2 * ans1) + k2 / 2.0) / (2.0 * g);
    18     printf("%.3f %.3f
    ", ans1, ans2);
    19 }
    20 int main(){
    21     int t;
    22     scanf("%d", &t);
    23     while(t--){
    24         scanf("%d %d %d", &v0, &k1, &k2);
    25         solve();
    26     }
    27 }

    题目:

    HAMSTER1 - Hamster flight

    There is a competition of flying hamsters in Hamsterburg. Each competing hamster is thrown from a sling. The judges rate the flight according to its length and height. Let X meters be the distance of the flight, and Y meters – maximum height to which the hamster rose during the flight. The hamster will receive K1*X + K2*Y points for such a flight. The initial speed of the hamsters is V0 m/s. Free fall acceleration is g = 10 m/s2. There is no air friction. The size of the hamster and the sling are negligible. When the hamster is thrown from the sling its height is 0 meters. You should determine the angle at which the hamster must be thrown so that he receives maximum points.

    Input

    The first line of input contains number t – the amount of tests. Then t tests follow one per line. The description of each test consists of three integers separated by single spaces. The first integer is V0, the second – K1, the third – K2.

    Constraints

    1 <= t <= 10000
    1 <= V0 <= 100
    0 <= K1, K2 <= 1000
    0 < K1 + K2

    Output

    For each test output the angle in radians at which the hamster must be thrown, and the amount of points it will receive. The numbers should be separated with spaces. Print the numbers with exactly three digits in the fractional part.

    Example

    Input:
    3
    10 10 0
    10 0 10
    10 10 10
    
    Output:
    0.785 100.000
    1.571 50.000
    0.908 128.078
    
     
  • 相关阅读:
    SQL Server中删除表中重复数据
    [Everyday Mathematics]20150121
    [Everyday Mathematics]20150120
    [Everyday Mathematics]20150119
    [Everyday Mathematics]20150118
    [Everyday Mathematics]20150117
    Hilbert先生旅馆的故事
    调和级数发散的简短证明
    [Everyday Mathematics]20150116
    [Everyday Mathematics]20150115
  • 原文地址:https://www.cnblogs.com/bolderic/p/7417105.html
Copyright © 2011-2022 走看看