摘要: 划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。 下面给出甲、乙两人的划拳记录,请你统计他们最后分别喝了多少杯酒。 阅读全文
posted @ 2019-02-28 22:08 王清河 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0 阅读全文
posted @ 2019-02-28 22:08 王清河 阅读(448) 评论(0) 推荐(0) 编辑
摘要: 著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元? 例如给定 $N = 5$, 排列是1、3、2、4、5。则: 1 阅读全文
posted @ 2019-02-28 22:07 王清河 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 火星人是以 13 进制计数的: 地球人的 0 被火星人称为 tret。 地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。 火星人将进位以后的 12 个高位数字分别称为:tam, hel, 阅读全文
posted @ 2019-02-28 22:06 王清河 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a​1​​a​0​​ with 0 for all i and a​k​​>0. Then N is palindrom 阅读全文
posted @ 2019-02-28 22:01 王清河 阅读(263) 评论(0) 推荐(0) 编辑
摘要: The "eight queens puzzle" is the problem of placing eight chess queens on an 8 chessboard so that no two queens threaten each other. Thus, a solution 阅读全文
posted @ 2019-02-28 22:00 王清河 阅读(368) 评论(0) 推荐(0) 编辑
摘要: John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from 阅读全文
posted @ 2019-02-28 21:59 王清河 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one 阅读全文
posted @ 2019-02-28 21:59 王清河 阅读(238) 评论(0) 推荐(0) 编辑
摘要: "Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can 阅读全文
posted @ 2019-02-28 21:58 王清河 阅读(222) 评论(0) 推荐(0) 编辑
摘要: Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are fri 阅读全文
posted @ 2019-02-28 21:57 王清河 阅读(222) 评论(0) 推荐(0) 编辑
摘要: "Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of th 阅读全文
posted @ 2019-02-28 21:57 王清河 阅读(322) 评论(0) 推荐(0) 编辑