标签:names stat nts target most targe constrain main SQ
Time limit : 2sec / Memory limit : 1000MB
Score: 100 points
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?
有两个人要吃一块大蛋糕,两人分别吃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; }
标签:names stat nts target most targe constrain main SQ
原文地址:https://www.cnblogs.com/FJ-LinHua/p/9192798.html