zoukankan      html  css  js  c++  java
  • A. Blackjack

    A. Blackjack

    time limit per test
     2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!

    Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to visit this splendid shrine of high culture.

    In Mainframe a standard pack of 52 cards is used to play blackjack. The pack contains cards of 13 values: 2, 3, 4, 5, 6, 7, 8, 9, 10, jacks, queens, kings and aces. Each value also exists in one of four suits: hearts, diamonds, clubs and spades. Also, each card earns some value in points assigned to it: cards with value from two to ten earn from 2 to 10 points, correspondingly. An ace can either earn 1 or 11, whatever the player wishes. The picture cards (king, queen and jack) earn 10 points. The number of points a card earns does not depend on the suit. The rules of the game are very simple. The player gets two cards, if the sum of points of those cards equals n, then the player wins, otherwise the player loses.

    The player has already got the first card, it's the queen of spades. To evaluate chances for victory, you should determine how many ways there are to get the second card so that the sum of points exactly equals n.

    Input

    The only line contains n (1 ≤ n ≤ 25) — the required sum of points.

    Output

    Print the numbers of ways to get the second card in the required way if the first card is the queen of spades.

    Examples

    input

    12

    output

    4

    input

    20

    output

    15

    input

    10

    output

    0

    Note

    In the first sample only four two's of different suits can earn the required sum of points.

    In the second sample we can use all tens, jacks, queens and kings; overall it's 15 cards, as the queen of spades (as any other card) is only present once in the pack of cards and it's already in use.

    In the third sample there is no card, that would add a zero to the current ten points.

    题意:一副扑克牌,一共52张,其中有2,3,4,5,6,7,8,9,10,J,Q,K,A。其中2~9的分值是相对应的数,A的分值可以是1或者11,然后10,J,Q,K的分值都是10.题目现在输入一个数,现在给你一张已经选好的牌Q,然后你从其中再选出一张其他的牌,使这两张牌的分值等于这个数。然后求出有几种不同的选取方式(注:每个数都是4中花色,分别是黑桃,梅花,红桃,方块)。题目意思很简单,就是分几种情况输出就行,不过要切记,判断大于21分的数值,他们都为0,我就是因为这个没判断,足足WA了8次(我真的是个大人才...)。

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    
    using namespace std;
    
    int main()
    {
        int n;
        while(~scanf("%d",&n)&&n)
        {
            n-=10;    //减10的原因是方便后面的计算
            if(n<=0||n>11)
                cout<<0<<endl;
            else if(n==10)
                cout<<15<<endl;
            else
                cout<<4<<endl;
        }
        return 0;
    }
  • 相关阅读:
    GitHub Android Libraries Top 100 简介
    GitHub Top 100 的项目(iOS)
    iOS 学习资源
    HTTP和GET/POST请求(NSURLConnection)
    RunLoop
    HTML5 拖放
    网络安全与加密
    Cocoapods的安装
    iOS中的单例模式
    SDWebImage
  • 原文地址:https://www.cnblogs.com/buhuiflydepig/p/10633398.html
Copyright © 2011-2022 走看看