pat
文章平均质量分 68
LchinaM
这个作者很懒,什么都没留下…
展开
-
130. Surrounded Regions
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X原创 2017-06-27 15:16:08 · 225 阅读 · 0 评论 -
1006. Sign In and Sign Out
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you原创 2015-02-27 18:44:56 · 438 阅读 · 0 评论 -
1012. 数字分类
给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字:A1 = 能被5整除的数字中所有偶数的和;A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算n1-n2+n3-n4...;A3 = 被5除后余2的数字的个数;A4 = 被5除后余3的数字的平均数,精确到小数点后1位;A5 = 被5除后余4的数字中最大数字。输入格式:每个输入包含1个测试用原创 2015-01-20 17:08:38 · 740 阅读 · 0 评论 -
1011. A+B和C
给定区间[-231, 231]内的3个整数A、B和C,请判断A+B是否大于C。输入格式:输入第1行给出正整数T(输出格式:对每组测试用例,在一行中输出“Case #X: true”如果A+B>C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。#include #include #include int main (){原创 2015-01-20 16:11:40 · 423 阅读 · 0 评论 -
1053. Path of Equal Weight
Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of all the nodes along the path from R原创 2015-03-10 17:58:45 · 493 阅读 · 0 评论 -
1043. Is It a Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The righ原创 2015-03-09 20:44:09 · 506 阅读 · 0 评论 -
1090. Highest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on原创 2015-03-08 16:30:21 · 640 阅读 · 0 评论 -
1059. Prime Factors
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.Input Specification:Each input file contains one test c原创 2015-03-06 20:11:29 · 538 阅读 · 0 评论 -
1046. Shortest Distance
The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file c原创 2015-03-05 21:56:35 · 412 阅读 · 0 评论 -
1008. Elevator
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec原创 2015-02-27 21:04:45 · 493 阅读 · 0 评论 -
1020. Tree Traversals
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor原创 2015-03-02 11:33:05 · 502 阅读 · 0 评论 -
1047. Student List for Course
Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input S原创 2015-03-05 22:49:34 · 468 阅读 · 0 评论 -
1027. Colors in Mars
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, where the first 2 digits are for Red, the middle 2 dig原创 2015-03-02 22:38:20 · 459 阅读 · 0 评论 -
1003. Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l原创 2015-02-27 11:32:14 · 498 阅读 · 0 评论 -
1033. 旧键盘打字
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?输入格式:输入在2行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过105个字符的串。可用的字符包括字母[a-z, A-Z]、数字0-9、以及下划线“_”(代表空格)、“,”、“.”、“-”、“+”(代原创 2015-01-23 15:48:43 · 909 阅读 · 0 评论 -
1070. Mooncake
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now原创 2015-03-07 17:05:50 · 614 阅读 · 0 评论 -
1061. Dating
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are a原创 2015-03-07 12:59:44 · 526 阅读 · 0 评论 -
1055. The World's Richest
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl原创 2015-03-06 16:40:41 · 624 阅读 · 0 评论 -
1051. Pop Sequence
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of t原创 2015-03-06 12:03:01 · 781 阅读 · 0 评论 -
1035. Password
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L原创 2015-03-03 21:28:03 · 463 阅读 · 0 评论 -
1025. PAT Ranking
Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w原创 2015-03-02 22:13:01 · 494 阅读 · 0 评论 -
1039. Course List for Student
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes原创 2015-03-04 12:03:49 · 506 阅读 · 0 评论 -
1001. A+B Format
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont原创 2015-01-26 20:05:37 · 502 阅读 · 0 评论 -
1031. 查验身份证
一个合法的身份证号码由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 3 4 5 6 7 8 9 10M:1 0 X 9 8 7 6 5 4 3 2原创 2015-01-23 14:33:13 · 717 阅读 · 0 评论 -
1016. 部分A+B
正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6。现给定A、DA、B、DB,请编写程序计算PA + PB。输入格式:输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 10。#include #include #include #defin原创 2015-01-21 17:07:57 · 648 阅读 · 0 评论 -
1013. 数素数
令Pi表示第i个素数。现任给两个正整数M 4,请输出PM到PN的所有素数。输入格式:输入在一行中给出M和N,其间以空格分隔。输出格式:输出从PM到PN的所有素数,每10个数字占1行,其间以空格分隔,但行末不得有多余空格。#include #include #include int main (){ int low,high; scanf("原创 2015-01-20 17:53:26 · 435 阅读 · 1 评论 -
1002. 写出这个数
读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1 空格,但一行中最后一个拼音数字后没有空格。#include #include #include #define N 100int myPrint(c原创 2015-01-20 14:09:09 · 365 阅读 · 0 评论 -
1003. 我要通过!
“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:1. 字符串中必须仅有P, A, T这三种字符,不可以包含其它字符;2. 任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串原创 2015-01-20 14:07:21 · 444 阅读 · 0 评论 -
1008. 数组元素循环右移问题
一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……AN-1)变换为(AN-M …… AN-1 A0 A1……AN-M-1)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式:每个输入包含一个测试用例,第1行输入N ( 1=0);第2行输入N个整数原创 2015-01-20 12:06:14 · 454 阅读 · 0 评论 -
1042. Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gambler原创 2015-03-05 11:50:14 · 501 阅读 · 0 评论 -
1043. Is It a Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The righ原创 2015-03-05 15:09:30 · 574 阅读 · 0 评论 -
1021. Deepest Root
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root原创 2015-03-02 13:23:29 · 586 阅读 · 0 评论 -
1019. General Palindromic Number
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. All single digit numbers are palindromic numbers原创 2015-03-01 21:46:39 · 368 阅读 · 0 评论 -
1011. World Cup Betting
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Si原创 2015-02-28 15:29:11 · 570 阅读 · 0 评论 -
1029. 旧键盘
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。输入格式:输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。输出格式:按照发现顺序,原创 2015-01-23 13:10:42 · 848 阅读 · 0 评论 -
1026. 程序运行时间
要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f执行完成后再调用c原创 2015-01-22 22:03:04 · 554 阅读 · 0 评论 -
1064. Complete Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The righ原创 2015-03-10 19:09:27 · 546 阅读 · 0 评论 -
1062. Talent and Virtue
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outstanding in both talent and virt原创 2015-03-07 14:29:31 · 506 阅读 · 0 评论 -
1052. Linked List Sorting
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give原创 2015-03-06 14:57:09 · 545 阅读 · 0 评论 -
1058. A+B in Hogwarts
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 Sickles to a Galleon and twenty-nine Knuts to a Si原创 2015-03-06 19:04:40 · 521 阅读 · 0 评论