摘要:
反转二叉树就是左右节点互换层遍历使用队列实现中序遍历递归实现The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck o... 阅读全文
posted @ 2015-12-06 12:39
白夜行zz
阅读(248)
评论(0)
推荐(0)
摘要:
递归算法,最后为了全部通过用了一些奇技淫巧。。。时间限制1200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You ... 阅读全文
posted @ 2015-12-06 12:39
白夜行zz
阅读(694)
评论(0)
推荐(0)
摘要:
make_heap 和 pop_heap 可以实现建堆的操作。另外要注意插入排序下一次可能和本次相同,要输出直到不同的时候的序列。时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertion sort iterates, consuming one input element e... 阅读全文
posted @ 2015-12-06 12:37
白夜行zz
阅读(227)
评论(0)
推荐(0)
摘要:
freopen("Text.txt", "r", stdin); 输入输出重定向,神器建立二叉树,注意中序遍历和指针的使用 时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA Binary Search Tree (BST) is recursively defined as a binary tree which has the... 阅读全文
posted @ 2015-12-06 12:37
白夜行zz
阅读(299)
评论(0)
推荐(0)
摘要:
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a... 阅读全文
posted @ 2015-12-06 12:36
白夜行zz
阅读(226)
评论(0)
推荐(0)
摘要:
n和i要用long long要不然乘着乘着就是负的了时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAmong all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be ... 阅读全文
posted @ 2015-12-06 12:35
白夜行zz
阅读(185)
评论(0)
推荐(0)
摘要:
(模拟题)时间限制220 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars c... 阅读全文
posted @ 2015-12-06 11:54
白夜行zz
阅读(241)
评论(0)
推荐(0)
摘要:
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input Sp... 阅读全文
posted @ 2015-12-06 11:53
白夜行zz
阅读(152)
评论(0)
推荐(0)
摘要:
result moded by 1000000007 就是 cout #include #include using namespace std;int main(void) { string s; cin >> s; long long int p=0, pa=0, pat=0; for (int i = 0; i < s.length(); i++) { if (s[i] == 'P') ... 阅读全文
posted @ 2015-12-06 11:52
白夜行zz
阅读(187)
评论(0)
推荐(0)
摘要:
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel... 阅读全文
posted @ 2015-12-06 11:51
白夜行zz
阅读(174)
评论(0)
推荐(0)
摘要:
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c... 阅读全文
posted @ 2015-12-06 11:50
白夜行zz
阅读(230)
评论(0)
推荐(0)
摘要:
时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to ... 阅读全文
posted @ 2015-12-06 11:49
白夜行zz
阅读(491)
评论(0)
推荐(0)
摘要:
(merge不能更坑。。。。)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. ... 阅读全文
posted @ 2015-12-06 11:47
白夜行zz
阅读(301)
评论(0)
推荐(0)
摘要:
For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test case,... 阅读全文
posted @ 2015-12-06 11:46
白夜行zz
阅读(310)
评论(0)
推荐(0)
摘要:
时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueIndeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost whil... 阅读全文
posted @ 2015-12-06 11:45
白夜行zz
阅读(183)
评论(0)
推荐(0)
摘要:
自己想的比较好的一个算法,时间大大节省时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CAO, PengGiven a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M ... 阅读全文
posted @ 2015-12-06 11:43
白夜行zz
阅读(148)
评论(0)
推荐(0)
摘要:
时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yuepush 的顺序就是二叉树的前序pop的顺序就是二叉树的中序遍历本质上还是考根据这两个顺序建立二叉树,并且进行后序遍历An inorder binary tree traversal can be implemented in a non-recursive way with a s... 阅读全文
posted @ 2015-12-06 11:43
白夜行zz
阅读(200)
评论(0)
推荐(0)
摘要:
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to t... 阅读全文
posted @ 2015-12-06 11:42
白夜行zz
阅读(173)
评论(0)
推荐(0)
摘要:
Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ... 阅读全文
posted @ 2015-12-06 11:41
白夜行zz
阅读(176)
评论(0)
推荐(0)
摘要:
屎一样的代码、、、、做完这个题就不想考试了、、、时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output "Fu" f... 阅读全文
posted @ 2015-12-06 11:40
白夜行zz
阅读(335)
评论(0)
推荐(0)
摘要:
Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integ... 阅读全文
posted @ 2015-12-06 11:39
白夜行zz
阅读(198)
评论(0)
推荐(0)
摘要:
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admissio... 阅读全文
posted @ 2015-12-06 11:38
白夜行zz
阅读(176)
评论(0)
推荐(0)
摘要:
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 the ... 阅读全文
posted @ 2015-12-06 11:37
白夜行zz
阅读(168)
评论(0)
推荐(0)
摘要:
挺坑的,现百度的二次探测法。The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be "... 阅读全文
posted @ 2015-12-06 11:36
白夜行zz
阅读(136)
评论(0)
推荐(0)
摘要:
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called ... 阅读全文
posted @ 2015-12-06 11:35
白夜行zz
阅读(233)
评论(0)
推荐(0)
摘要:
The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file contai... 阅读全文
posted @ 2015-12-06 11:34
白夜行zz
阅读(180)
评论(0)
推荐(0)
摘要:
输入需要稍作变换,变为一个每个人和他的关注者的map 而不是他和他的关注人、然后bfs搜索。注意搜索层数的要求。Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a so... 阅读全文
posted @ 2015-12-06 11:34
白夜行zz
阅读(180)
评论(0)
推荐(0)
摘要:
reverse 方法很好用时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given... 阅读全文
posted @ 2015-12-06 11:33
白夜行zz
阅读(232)
评论(0)
推荐(0)
摘要:
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9]"."[0-9]+E[+-][0-9]+ which means that the in... 阅读全文
posted @ 2015-12-06 11:31
白夜行zz
阅读(152)
评论(0)
推荐(0)
摘要:
map的使用时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者HOU, QimingPeople often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "th... 阅读全文
posted @ 2015-12-06 11:29
白夜行zz
阅读(180)
评论(0)
推荐(0)
摘要:
dij适合计算单源最短路径,计算一个源到各个点的距离比较快dfs不适合算每个点到每个点的距离,迭代次数太多、时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA gas station has to be built at such a location that the minimum distance between the s... 阅读全文
posted @ 2015-12-06 11:29
白夜行zz
阅读(389)
评论(0)
推荐(0)
摘要:
(库存量也是double)时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueMooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be... 阅读全文
posted @ 2015-12-06 11:27
白夜行zz
阅读(170)
评论(0)
推荐(0)
摘要:
For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by takin... 阅读全文
posted @ 2015-12-06 11:26
白夜行zz
阅读(294)
评论(0)
推荐(0)
摘要:
Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2... 阅读全文
posted @ 2015-12-06 11:25
白夜行zz
阅读(179)
评论(0)
推荐(0)
摘要:
动态背包题意:给定一系列的硬币值, 然后给定一个目标value, 从所有硬币中找出几个, 使得这几个硬币的和正好等于这个value, 而且这个硬币序列应该是满足硬币值字典序的最小序列.分析:属于典型的背包问题. 用动态规划(dp)做, 假设F(N, M)表示不超过面值M, 而且从前面N个硬币中挑选硬币值能得到的最大硬币面值总和, 那我们可以得到如下递归公式:F(N, M) = max{ F(N–... 阅读全文
posted @ 2015-12-06 11:25
白夜行zz
阅读(200)
评论(0)
推荐(0)
摘要:
时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAn AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; i... 阅读全文
posted @ 2015-12-06 11:24
白夜行zz
阅读(187)
评论(0)
推荐(0)
摘要:
要输入字符串,longlongint不够时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者HOU, QimingGiven three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification:The first l... 阅读全文
posted @ 2015-12-06 11:22
白夜行zz
阅读(159)
评论(0)
推荐(0)
摘要:
根据中序遍历建立完全二叉树。时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node... 阅读全文
posted @ 2015-12-06 11:19
白夜行zz
阅读(143)
评论(0)
推荐(0)
摘要:
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct num... 阅读全文
posted @ 2015-12-06 11:18
白夜行zz
阅读(237)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2015-12-06 11:17
白夜行zz
阅读(170)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2015-12-06 11:16
白夜行zz
阅读(168)
评论(0)
推荐(0)
摘要:
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 case whic... 阅读全文
posted @ 2015-12-06 11:14
白夜行zz
阅读(136)
评论(0)
推荐(0)
摘要:
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping. Now given the number of significa... 阅读全文
posted @ 2015-12-06 11:14
白夜行zz
阅读(190)
评论(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 Sickles to a Galleon and twenty-nine Knuts to a Si... 阅读全文
posted @ 2015-12-06 11:13
白夜行zz
阅读(168)
评论(0)
推荐(0)
摘要:
set的使用和它的迭代器的使用Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top p... 阅读全文
posted @ 2015-12-06 11:12
白夜行zz
阅读(124)
评论(0)
推荐(0)
摘要:
使用队列来模拟还在的人时间限制30 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueMice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a... 阅读全文
posted @ 2015-12-06 11:11
白夜行zz
阅读(191)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2015-12-06 11:10
白夜行zz
阅读(128)
评论(0)
推荐(0)
摘要:
挺简单的,多占内存,少用循环Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area i... 阅读全文
posted @ 2015-12-06 11:07
白夜行zz
阅读(189)
评论(0)
推荐(0)
摘要:
dfs函数携带vector形参记录搜索路径时间限制10 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven 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 ... 阅读全文
posted @ 2015-12-06 11:06
白夜行zz
阅读(168)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2015-12-06 11:05
白夜行zz
阅读(157)
评论(0)
推荐(0)
摘要:
用一个vector 模拟栈每次检查输入,如果大于上次出栈的检查是否满足范围要求。满足的话将中间的数压栈如果小于上次出栈的检查是否为栈尾。满足的话最后一个数出栈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 ... 阅读全文
posted @ 2015-12-06 11:02
白夜行zz
阅读(203)
评论(0)
推荐(0)
摘要:
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However, i... 阅读全文
posted @ 2015-12-06 11:01
白夜行zz
阅读(229)
评论(0)
推荐(1)
摘要:
The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's i... 阅读全文
posted @ 2015-12-06 11:00
白夜行zz
阅读(155)
评论(0)
推荐(0)
摘要:
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However,... 阅读全文
posted @ 2015-12-06 11:00
白夜行zz
阅读(133)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制64000 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to ou... 阅读全文
posted @ 2015-12-06 10:59
白夜行zz
阅读(441)
评论(0)
推荐(0)
摘要:
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 contains ... 阅读全文
posted @ 2015-12-06 10:58
白夜行zz
阅读(140)
评论(0)
推荐(0)
摘要:
LCS 最大公共子序列。 memset函数需要include 时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueEva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors ... 阅读全文
posted @ 2015-12-06 10:57
白夜行zz
阅读(255)
评论(0)
推荐(0)
摘要:
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position ... 阅读全文
posted @ 2015-12-06 10:55
白夜行zz
阅读(173)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yue(二叉树建立方法)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node cont... 阅读全文
posted @ 2015-12-06 10:52
白夜行zz
阅读(158)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueShuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to av... 阅读全文
posted @ 2015-12-06 10:51
白夜行zz
阅读(152)
评论(0)
推荐(0)
摘要:
注意n的值很大的时候不能使用两层嵌套算法,这样执行时间将会很长时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueBeing unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of... 阅读全文
posted @ 2015-12-06 10:49
白夜行zz
阅读(218)
评论(0)
推荐(0)
摘要:
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest symmetric sub-string is "s PAT&TAP s", hence you must... 阅读全文
posted @ 2015-12-06 10:46
白夜行zz
阅读(188)
评论(0)
推荐(0)
摘要:
1039. Course List for Student (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all th... 阅读全文
posted @ 2015-12-06 10:44
白夜行zz
阅读(179)
评论(0)
推荐(0)
摘要:
1,注意加法越界的问题,用long long可以存一次和,相加之后要写加法器来做2,注意vector 中是用 size() 函数来表示其内部的个数的。 结尾附上常用vector函数The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning th... 阅读全文
posted @ 2015-12-06 10:43
白夜行zz
阅读(151)
评论(0)
推荐(0)
摘要:
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-0229-8... 阅读全文
posted @ 2015-12-06 10:43
白夜行zz
阅读(191)
评论(0)
推荐(0)
摘要:
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one test ... 阅读全文
posted @ 2015-12-06 10:42
白夜行zz
阅读(210)
评论(0)
推荐(0)
摘要:
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 ... 阅读全文
posted @ 2015-12-06 10:41
白夜行zz
阅读(154)
评论(0)
推荐(0)
摘要:
贪心算法的模拟题。时间限制10 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者ZHANG, GuochuanWith highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited,... 阅读全文
posted @ 2015-12-06 10:40
白夜行zz
阅读(174)
评论(0)
推荐(0)
摘要:
注意这里n是电话数,电话数不超过1000代表人数不超过两千,。。。好坑。。。。时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueOne way that the police finds the head of a gang is to check people's phone calls. If there is a phone ... 阅读全文
posted @ 2015-12-06 10:40
白夜行zz
阅读(141)
评论(0)
推荐(0)
摘要:
时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueTo store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share th... 阅读全文
posted @ 2015-12-06 10:37
白夜行zz
阅读(139)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven 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:... 阅读全文
posted @ 2015-12-06 10:36
白夜行zz
阅读(151)
评论(0)
推荐(0)
摘要:
1,注意algorithm 里面有merge函数2,scanf 比cin快许多,大约是后者1/33,输入long int 用scanf("%ld", &a[i]); 是小写的l时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven an increasing sequence S of N integers, the med... 阅读全文
posted @ 2015-12-06 10:35
白夜行zz
阅读(167)
评论(0)
推荐(1)
摘要:
dfs使用vector保存最短路径时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are s... 阅读全文
posted @ 2015-12-06 10:35
白夜行zz
阅读(233)
评论(0)
推荐(0)
摘要:
printf 比cout 执行要快时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueExcel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file contains o... 阅读全文
posted @ 2015-12-06 10:34
白夜行zz
阅读(133)
评论(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, where the first 2 digits are for Red, the middle 2 dig... 阅读全文
posted @ 2015-12-06 10:33
白夜行zz
阅读(133)
评论(0)
推荐(0)
摘要:
注意数据合法性的检测。26分的时候 有人打了两个多小时,只能打两个小时,有人9点之后来的,要排除。时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA table tennis club has N tables available to the public. The tables are numbered from 1 to ... 阅读全文
posted @ 2015-12-06 10:30
白夜行zz
阅读(400)
评论(0)
推荐(0)
摘要:
尽量避免二次循环,很容易运行超时。该算法用printf 用时30ms 使用cout 运行75ms,只差这一句话。所以输出很多的时候不应该使用coutg++ 编译器使用 strcmp 一定要引用 string.h 头Programming Ability Test (PAT) is organized by the College of Computer Science and Technology... 阅读全文
posted @ 2015-12-06 10:29
白夜行zz
阅读(193)
评论(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. All single digit numbers are palindromic numbers... 阅读全文
posted @ 2015-12-06 10:28
白夜行zz
阅读(325)
评论(0)
推荐(0)
摘要:
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con... 阅读全文
posted @ 2015-12-06 10:25
白夜行zz
阅读(162)
评论(0)
推荐(0)
摘要:
A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a... 阅读全文
posted @ 2015-12-06 10:24
白夜行zz
阅读(219)
评论(0)
推荐(0)
摘要:
首先计算连通分量。dfs然后分两种情况,n数目很小的时候对每个节点dfs,n大的时候超时n数目大的时候计算只具有单边的节点数。n小的时候答案错误两者结合就好了,当然这是一种不可取的办法。。。。。A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the ... 阅读全文
posted @ 2015-12-06 10:22
白夜行zz
阅读(206)
评论(0)
推荐(0)
摘要:
根据两种遍历方式建立二叉树层遍历二叉树时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequen... 阅读全文
posted @ 2015-12-06 10:19
白夜行zz
阅读(135)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromi... 阅读全文
posted @ 2015-12-06 10:18
白夜行zz
阅读(148)
评论(0)
推荐(0)
摘要:
比较复杂的dfs 注意算好到底需要send多少take back多少时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThere is a public bike service in Hangzhou City which provides great convenience to the tourists from all ov... 阅读全文
posted @ 2015-12-06 10:18
白夜行zz
阅读(145)
评论(0)
推荐(0)
摘要:
排队模型时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two part... 阅读全文
posted @ 2015-12-06 10:17
白夜行zz
阅读(158)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yue 去掉非法数据计算账单A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amoun... 阅读全文
posted @ 2015-12-06 10:17
白夜行zz
阅读(305)
评论(0)
推荐(0)
摘要:
1,不同基底的反数算法,2,输入 cin 使用A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its ... 阅读全文
posted @ 2015-12-06 10:15
白夜行zz
阅读(131)
评论(0)
推荐(0)
摘要:
排队模型先把每个窗口的黄线排满如果还有人的话,前面完事儿一个插入一个。最后把每个队伍的人服务完。时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose a bank has N windows open for service. There is a yellow line in front of the windows ... 阅读全文
posted @ 2015-12-06 10:14
白夜行zz
阅读(182)
评论(0)
推荐(0)
摘要:
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee... 阅读全文
posted @ 2015-12-06 10:12
白夜行zz
阅读(122)
评论(0)
推荐(0)
摘要:
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E - Eng... 阅读全文
posted @ 2015-12-06 10:11
白夜行zz
阅读(209)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueWith the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams ... 阅读全文
posted @ 2015-12-06 10:07
白夜行zz
阅读(149)
评论(0)
推荐(0)
摘要:
简直是哭着做出来的,起码提交了22遍。创纪录了。。。首先不能像上次那样枚举进制数,那样输入987654321 10 1 10 的话十分钟都算不完,题中只有一个超时很照顾人了。。。考虑近似计算,利用y=a*x^n+b 算出n,进制数如果有,也不会超过n,因此考虑由n向下寻找。注意,进制数不能小于数中最大的数字。如果将两个数字作为字符串输入,注意排除字符串前面的0.时间限制400 ms内存限制6553... 阅读全文
posted @ 2015-12-06 10:06
白夜行zz
阅读(170)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe 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 ... 阅读全文
posted @ 2015-12-06 09:59
白夜行zz
阅读(156)
评论(0)
推荐(0)
摘要:
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 #include #include using namespace std;vector num;int main(void) { int n; ci... 阅读全文
posted @ 2015-12-06 09:57
白夜行zz
阅读(131)
评论(0)
推荐(0)
摘要:
注意字符串的输入方法char a[100] = { 0 };scanf("%s", &a);时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven a non-negative integer N, your task is to compute the sum of all the digits of N, and outp... 阅读全文
posted @ 2015-12-06 09:55
白夜行zz
阅读(190)
评论(0)
推荐(0)
摘要:
注意:1,结构体的应用。2,向量的应用,#include vectorp; 用于不定数目的时候的数组创建3,cin 和cout的使用,#include4,字符串的使用 用#include 可以使用string s;时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAt the beginning of every day, t... 阅读全文
posted @ 2015-12-06 09:55
白夜行zz
阅读(162)
评论(0)
推荐(0)
摘要:
使用map保存树,使用DFS进行树的搜索时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.In... 阅读全文
posted @ 2015-12-06 09:49
白夜行zz
阅读(183)
评论(0)
推荐(0)
摘要:
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... 阅读全文
posted @ 2015-12-06 09:48
白夜行zz
阅读(184)
评论(0)
推荐(0)
摘要:
注意输入输出的:1,输入小数的语句 scanf("%lf", &a)2,输出一位小数的语句 printf("%.1f", count);时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThis time, you are supposed to find A+B where A and B are two polynomials.... 阅读全文
posted @ 2015-12-06 09:47
白夜行zz
阅读(213)
评论(0)
推荐(0)
摘要:
时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueCalculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there ar... 阅读全文
posted @ 2015-12-06 09:43
白夜行zz
阅读(131)
评论(0)
推荐(0)
浙公网安备 33010602011771号