摘要: 一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下: 首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值Z;最后按照以下关系对应Z值与校验码M的值: Z:0 1 2 阅读全文
posted @ 2018-03-11 10:52 王清河 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 让我们用字母B来表示“百”、字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。 输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。 输出格式 阅读全文
posted @ 2018-03-11 08:52 王清河 阅读(86) 评论(0) 推荐(0) 编辑
摘要: If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver 阅读全文
posted @ 2018-03-10 19:28 王清河 阅读(113) 评论(0) 推荐(0) 编辑
摘要: People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, wher 阅读全文
posted @ 2018-03-10 19:10 王清河 阅读(155) 评论(0) 推荐(0) 编辑
摘要: A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number 阅读全文
posted @ 2018-03-10 17:03 王清河 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一个西可,很容易。”现在,给定哈利应付的价钱P和他实付的钱A,你的任务是写一个程序来计算他应该被找的零钱。 输入格式: 输入在1行 阅读全文
posted @ 2018-03-10 16:42 王清河 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as: That is 阅读全文
posted @ 2018-03-10 15:05 王清河 阅读(113) 评论(0) 推荐(0) 编辑
摘要: A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a progra 阅读全文
posted @ 2018-03-10 09:44 王清河 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。 给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能 阅读全文
posted @ 2018-03-09 16:18 王清河 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧! 输入格式: 输入在一行中给出正方形边长N(3<=N<=20)和组成正方 阅读全文
posted @ 2018-03-09 13:08 王清河 阅读(113) 评论(0) 推荐(0) 编辑