zoukankan      html  css  js  c++  java
  • UESTC 1034 AC Milan VS Juventus 分情况讨论

    AC Milan VS Juventus

    Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
     

    Kennethsnow and Hlwt both love football.

    One day, Kennethsnow wants to review the match in 2003 between AC Milan and Juventus for the Championship Cup. But before the 

    penalty shootout. he fell asleep.

    The next day, he asked Hlwt for the result. Hlwt said that it scored a:b in the penalty shootout.

    Kennethsnow had some doubt about what Hlwt said because Hlwt is a fan of Juventus but Kennethsnow loves AC Milan.

    So he wanted to know whether the result can be a legal result of a penalty shootout. If it can be, output Yes, otherwise output No.

    The rule of penalty shootout is as follows:

    • There will be 5 turns, in each turn, 2 teams each should take a penalty shoot. If goal, the team get 1 point. After each shoot, if the 

    • winner can be confirmed(i.e: no matter what happened after this shoot, the winner will not change), the match end immediately.

    • If after 5 turns the 2 teams score the same point. A new turn will be added, until that one team get a point and the other not in a turn.

    Before the penalty shootout begins, the chief referee will decide which team will take the shoot first, and afterwards, two teams will take shoot 

    one after the other. Since Kennethsnow fell asleep last night, he had no idea whether AC Milan or Juventus took the first shoot.

    Input

    The only line contains 2 integers ab. Means the result that Hlwt said.

    0a,b10    

    Output

    Output a string Yes or No, means whether the result is legal.

    Sample input and output

    Sample Input Sample Output
    3 2
    Yes
    2 5
    No

    Hint

    The Sample 1 is the actual result of the match in 2003.

    The Sample 2, when it is 2:4 after 4 turns, AC Milan can score at most 1point in the next turn. So Juventus has win when it is 2:4. So the result cannot be 22:55.

    This story happened in a parallel universe. In this world where we live, kennethsnow is a fan of Real Madrid.

    Source

    The 13th UESTC Programming Contest Preliminary
    The question is from here.

    My Solution

    分情况讨论清楚就好。然后注意 a == b 的时候也是No
    把分类出来的区间理清楚。不要条件里面混杂着不该包括的东西

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    
    int main()
    {
        int a, b;
        scanf("%d%d", &a, &b);
        if(a == b )printf("No");
        else if((a == 5 && b <5) || (b == 5&& a <5)) {if(abs(a-b) >= 3) printf("No");else printf("Yes"); }  //!!
        else if(a < 5 && b <5) {if(abs(a-b) >= 4) printf("No");else printf("Yes"); }
        else {if(abs(a-b) > 1) printf("No");else printf("Yes"); }
        return 0;
    }

    Thank you all!

  • 相关阅读:
    为什么基于TCP的应用需要心跳包(TCP keep-alive原理分析)
    「DDoS攻击」兴风作浪,教你如何有效防护!
    你还敢乱粘贴吗?
    TODO git如何去掉烦人的merge?
    Git修改已经push到远程的commit信息
    Oracle删除唯一索引失败提示ORA-01418:指定的索引不存在 ORACLE
    mybatis逆向生成代码 [ERROR] No plugin found for prefix 'mybatis-generator' in the current project and in the plugin groups
    MySQL 中 redo log、undo log、binlog 的总结
    VATT: Transformers for Multimodal Self-Supervised Learning from Raw Video, Audio and Text
    OPT: Omni-Perception Pre-Trainer for Cross-Modal Understanding and Generation
  • 原文地址:https://www.cnblogs.com/mthoutai/p/7403617.html
Copyright © 2011-2022 走看看