zoukankan      html  css  js  c++  java
  • A.Gennady and a Card Game

    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

    To play Mau-Mau, you need a pack of 5252 cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

    At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

    In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

    Input

    The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

    Each string is two characters long. The first character denotes the rank and belongs to the set {2,3,4,5,6,7,8,9,T,J,Q,K,A}{2,3,4,5,6,7,8,9,T,J,Q,K,A}. The second character denotes the suit and belongs to the set {D,C,S,H}{D,C,S,H}.

    All the cards in the input are different.

    Output

    If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

    You can print each letter in any case (upper or lower).

    Examples
    input
    AS
    2H 4C TH JH AD
    
    output
    YES
    
    input
    2H
    3D 4C AC KD AS
    
    output
    NO
    
    input
    4D
    AS AC AD AH 5H
    
    output
    YES
    
    Note

    In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

    In the second example, you cannot play any card.

    In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

    简单粗暴,不解释

     1 #include<stdio.h>
     2 #include<string.h>
     3 int main(){
     4     char a[100];
     5     char b[100000];
     6     gets(a);
     7     gets(b);
     8     int flag = 0;
     9     //printf("%c",b[1]);
    10     for(int i = 0;i<strlen(b);i++){
    11         if(a[0]==b[i]||a[1]==b[i])
    12         flag = 1;
    13     }
    14     if(flag)
    15     printf("YES");
    16     else
    17     printf("NO");
    18 }
    View Code
  • 相关阅读:
    Oracle查询错误分析:ORA-01791:不是SELECTed表达式
    Java中DESKeySpec类
    linux发布项目
    mac下搭建cocos2d-x2.2.1版本android编译环境教程
    使用Eigen求解线性方程组
    视觉SLAM十四讲课后答案-ch1
    costmap_2d: obstacle_layer中关于激光雷达障碍物清除不干净的解决
    ch4 激光的前端配准算法一 —— ICP方法
    Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir, which is not found.
    ch3 传感器数据处理II: 激光雷达运动畸变去除
  • 原文地址:https://www.cnblogs.com/DWVictor/p/10224882.html
Copyright © 2011-2022 走看看