3.14牛客2021年度训练联盟热身训练赛第二场G.Plate Spinning[思维]

时间限制:C/C++ 1秒,其他语言2秒

空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述 

Plate  spinning  is  a  circus  act  where  a  person  spins  various  objects(usually  plates  and  bowls)  on  poles  without  them  falling  off.   It involves spinning an object and then returning back to the object in order to add additional speed to prevent it from falling off the pole.
 In this problem you will simulate plate spinning where the plates are placed in a circular arrangement (much like the picture to the right).  You  must  determine  whether  Chester the  Clown  will  be  able  to maintain the plates spinning or whether one or more plates will end up falling off poles.   

The Problem:

Given the number of poles/plates in a circular arrangement and the speed up to which Chester the Clown spins the plates (in degrees per second), determine if he can maintain the act or if plates will fall.  For this problem, we will assume that plates degrade (slow down) at a constant rate of 5-degrees-per-second per second and that Chester can move from one pole to any other pole in 0.5 seconds.  In addition, assume that Chester can spin up a plate with zero time cost.
 A plate falls off when its rate is zero.  However, if Chester arrives at a plate exactly at the same time  the  rate  reaches  zero,  Chester  will  spin  the plate  and  prevents  it  from  falling,  i.e., the  rate must reach zero before Chester arrives for the plate to fall.  

输入描述:

 

The first line of the input will be a single positive integer, a, representing the number of acts to evaluate.  Each of the following a lines will represent a single act and will contain two positive integers, n and p, separated by a single space, where n represents the number of poles (1 ≤ n ≤ 15)  and  p represents  the  speed  up  to  which  Chester spins  a  plate  (0  <  p ≤ 100)  in  degrees  per second.  At the very beginning of each act, all plates are initially spinning at this speed, and he is currently at a plate in the circle (he can  choose  which plate to start at in order to maximize his chance of success).  

输出描述:

 

For each circus act, output a header “Circus Act i:” on a line by itself where i is the number of  the  act  (starting  with  1).   Then,  on  the  next  line,  output  “Chester  can  do  it!”  if Chester can maintain the act, or output  “Chester will fail!” if one or more plates will fall.  Leave a blank line after the output for each test case. 

示例1

输入

复制

3
2 10
5 7
2 12

输出

复制

Circus Act 1:
Chester can do it!

Circus Act 2:
Chester will fail!

Circus Act 3:
Chester can do it!

✖一开始公式推错了,应该是(n*2.5)<=p

✖特判输入1

wa

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
#define Inf 0xfffffff
#define N 501000
#define eps 1e-7
using namespace std;
 
int main()
{
    int a;
    cin>>a;
    int ac=1;
    while(ac<=a)
    {
        int n,p;
        cin>>n>>p;
        double t=(n-1)*0.5;
        cout<<"Circus Act "<<ac<<":"<<endl;
        if(t*5<=p)
            cout<<"Chester can do it!"<<endl;
        else
            cout<<"Chester will fail!"<<endl;
        if(ac!=a)
            cout<<endl;
        ac++;
    }
    
    return 0;
}

ac

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
#define Inf 0xfffffff
#define N 501000
#define eps 1e-7
using namespace std;
 
int main()
{
    int a;
    cin>>a;
    int ac=1;
    while(ac<=a)
    {
        double n,p;
        cin>>n>>p;
        cout<<"Circus Act "<<ac<<":"<<endl;
        //cout<<n*2.5<<" "<<p<<endl;
        if(n==1)
        {
            cout<<"Chester can do it!"<<endl;
        }
        else
        {
            if((n*2.5)<=p)
                cout<<"Chester can do it!"<<endl;
            else
                cout<<"Chester will fail!"<<endl;
        }
        if(ac!=a)
            cout<<endl;
        ac++;
    }
    
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值