Hdu 2060 Snooker (Math Problem)

Source: Internet
Author: User

Hdu 2060 Snooker (Math Problem)

Question: There are n balls on the table. One score is a and the other score is B. Ask if the score can be exceeded (or equal to) if the first person scores all n balls) the second person.

Analysis: 1. If n> 6, there are 6 colored balls and a n-6 of red balls on the table. Every time you hit a red ball, you have to make up a black ball.

(N-6) * 1 + (n-6) * 7 + 2 + 3 + 4 + 5 + 6 + 7

2. If n is <= 6, then there are n values left on the table, for example, when n = 1, there will be one black ball left, and the score for n is

(7 + 7-n + 1) * n/2.

Code:

 

#include
 
  #include
  
   using namespace std;int main(){    int n,a,b;    int t;    scanf("%d",&t);    while(t--)    {        scanf("%d%d%d",&n,&a,&b);        if(n>6)        {            if(a+(n-6)*1+(n-6)*7+2+3+4+5+6+7>=b)            {                printf("Yes\n");            }            else                printf("No\n");        }        else        {            if(a+(7+7-n+1)*n/2>=b)                printf("Yes\n");            else                printf("No\n");        }    }    return 0;}
  
 


 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.