码迷,mamicode.com
首页 > 移动开发 > 详细

[ABC 100] A-Happy Birthday!

时间:2018-06-17 15:07:03      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:names   stat   nts   target   most   targe   constrain   main   SQ   

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!

标签:names   stat   nts   target   most   targe   constrain   main   SQ   

原文地址:https://www.cnblogs.com/FJ-LinHua/p/9192798.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!