[ABC 100] A-Happy Birthday!

來源:互聯網
上載者:User

標籤: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!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.