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;}