A. Blackjack
A. Blackjack
2 seconds
256 megabytes
standard input
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的原因是方便后面的计算
if(n<=||n>)
cout<<<<endl;
else if(n==)
cout<<<<endl;
else
cout<<<<endl;
}
return ;
}
A. Blackjack的更多相关文章
- Mini projects #6 ---- Blackjack
课程全名:An Introduction to Interactive Programming in Python,来自 Rice University 授课教授:Joe Warren, Scott ...
- BlackJack Strategy
GAME SPEC: 2-deck, 104 cards total. Bellagio has 2-deck and 6-deck games. based on hard 17, dealer h ...
- [CareerCup] 8.1 Implement Blackjack 实现21点纸牌
8.1 Design the data structures for a generic deck of cards. Explain how you would subclass the data ...
- python面对对象编程----1:BlackJack(21点)
昨天读完了<Mastering Object-oriented Python>的第一部分,做一些总结. 首先,第一部分总过八章,名字叫Pythonic Classes via Specia ...
- 逆向分析一款国外Blackjack Card Counter软件并附上License生成脚本
没有学过逆向,一时兴起,搞了一下这个小软件,名为“逆向分析”,其实过程非常简单,难登大雅之堂,就当段子看吧.首先介绍一下背景吧.这是一款国外的Blackjack也就是21点算牌软件,我从来不玩牌的,机 ...
- 2017第十三届湖南省省赛B - Simplified Blackjack CSU - 1998
在一次聚会上,Bob打算和Alice一起玩Blackjack游戏,但Alice平时很少玩扑克类游戏,Bob觉得跟Alice解释清楚Blackjack的规则有点困难,于是Bob决定和Alice玩一次简化 ...
- [360前端星计划]BlackJack(21点)(纯JS,附总部学习笔记)
[360前端星计划]总部学习笔记(6/6) [360前端星计划]详情跳转 游戏界面预览 目录 一.游戏介绍 1.起源 2.规则 3.技巧 二.游戏设计 1.整体UI构思 2.素材采集 3.游戏总规划 ...
- 【pwnable.kr】blackjack
又一道pwnable nc pwnable.kr 9009 读题找到源代码在:http://cboard.cprogramming.com/c-programming/114023-simple-bl ...
- [MIT6.006] 20. Daynamic Programming II: Text Justification, Blackjack 动态规划II:文本对齐,黑杰克
这节课通过讲解动态规划在文本对齐(Text Justification)和黑杰克(Blackjack)上的求解过程,来帮助我们理解动态规划的通用求解的五个步骤: 动态规划求解的五个"简单&q ...
随机推荐
- Django之自定义标签,过滤器,以及inclusion_tag
目录 Django之自定义标签,过滤器,以及inclusion_tag 自定义过滤器 自定义标签 inclusion_tag inclusion_tag() 项目实例: inclusion_tag() ...
- linux下vim常用命令 (更新中...)
1.注释多行 1). 首先按esc进入命令行模式下,按下Ctrl + v,进入VISUAL BLOCK模式; 2). 在行首使用上下键选择需要注释的多行; 3). 按下键盘(大写)“I”键,进入插入模 ...
- selenium自动化测试工具模拟登陆爬取当当网top500畅销书单
selenium自动化测试工具可谓是爬虫的利器,基本动态加载的网页都能抓取,当然随着大型网站的更新,也出现针对selenium的反爬,有些网站可以识别你是否用的是selenium访问,然后对你加以限制 ...
- luogu P2605 [ZJOI2010]基站选址
luogu 先考虑朴素dp,设\(f_{i,j}\)表示在第\(i\)个村庄放了基站,一共放了\(j\)次,且只考虑前面村庄影响的答案.这里可以把\(j\)放在外面枚举,然后从\(f_{k,j-1}( ...
- 冒泡排序(java可直接跑,算法思想等小儿科不多说直接上代码)
import java.util.Arrays; /** *冒泡排序:时间复杂度O(N^2),空间复杂度O(1),稳定的排序 * 每趟确定一个元素的位置,所以需要arr.length趟排序, */pu ...
- 多线程编程-- part5.1 互斥锁ReentrantLock
ReentrantLock简介 Reentrantlock是一个可重入的互斥锁,又被称为独占锁. Reentrantlock:分为公平锁和非公平锁,它们的区别体现在获取锁的机制上是否公平.“锁”是为了 ...
- 12、rpm
1.什么是rpm 由红帽开发用于软件包的安装 升级 卸载 查询 2.rpm包是什么样? 组成部分是什么样的? zip-3.0-11.el7.x86_64.rpm #el7 zip-3.0-1. el6 ...
- 微信公众号开发者中心配置 Token验证失败 终极解决方案
请您检查这几项: 1. 在您的URL(服务器地址)页面里,直接Get获取echostr参数打印到页面上. 在火狐浏览器里Firebug里面看到echostr前面多了几个乱码. 把您开发者设置的URL页 ...
- SpringMVC获取HttpClient 请求的数据
package com.nnk.upstream.controller;import org.springframework.util.StreamUtils;import javax.servlet ...
- 关于Vue-$router传参出现刷新页面或者返回页面丢失数据的问题
也算是踩到坑了,但不是我踩到的,不过还是得说下这个问题,很严重,对于小白和初学者是比较有帮助的,如果使用到路由传参,请选择你想要的传参方式params或者query 1.query this.$rou ...