[ABC 100] A-Happy Birthday!

丈夫欲遂平生志,一载寒窗一举汤。这篇文章主要讲述[ABC 100] A-Happy Birthday!相关的知识,希望能为你提供帮助。
A - Happy Birthday!Time limit  : 2sec /  Memory limit  : 1000MB
Score:  100  points
Problem Statement
E869120‘s and square1001‘s  16-th birthday is coming soon.
Takahashi from AtCoder Kingdom gave them a round cake cut into  16  equal fan-shaped pieces.
E869120 and square1001 were just about to eat  A  and  B  of those pieces, respectively,
when they found a note attached to the cake saying that "the same person should not take two adjacent pieces of cake".
Can both of them obey the instruction in the note and take desired numbers of pieces of cake?
Constraints

  • A  and  B  are integers between  1  and  16  (inclusive).
  • A+B  is at most  16.
[题目解释]
有两个人要吃一块大蛋糕,两人分别吃A,B块,规定一个人不能吃相邻的两块蛋糕.问他们能否吃到蛋糕?
[题目解析]
由抽屉原理可知当一个人吃8块时每两块蛋糕中间隔1块蛋糕,当一个人吃九块时必定有一块相邻的两块蛋糕.于是我们只要保证A,B均满足小于等于8即可.
[代码]
/* Name: Happy Birthday! Author: FZSZ-LinHua Date: 2018 06 16 Exec time: 1ms Memory usage: 256KB Score: 100 Algorithm: Brute-force */ # include "iostream" # include "cstdio"using namespace std; int a,b; int main(){ scanf("%d%d",& a,& b); if(a< =8 & & b< =8){ printf("Yay!"); }else{ printf(":("); } return 0; }

【[ABC 100] A-Happy Birthday!】 



    推荐阅读