摘要:LeetCode: LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set....
阅读全文
随笔分类 - C/C++
摘要:LeetCode: LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set....
阅读全文
摘要:LeetCode: Insertion Sort ListSort a linked list using insertion sort.地址:https://oj.leetcode.com/problems/insertion-sort-list/算法:按题目的意思,采用插入排序对链表进行排序,时...
阅读全文
摘要:LeetCode: Sort ListSort a linked list in O(n log n) time using constant space complexity.地址:https://oj.leetcode.com/problems/sort-list/算法:采用分治的思想,首先利用...
阅读全文
摘要:LeetCode: Max Points on a LineGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.地址:https://oj.leetcod...
阅读全文
摘要:LeetCode: Reverse Words in a String:Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression in Reverse Polish Notation.Valid op...
阅读全文
摘要:昨天在微博上看到王道论坛说晚上有机试练习赛(http://ac.jobdu.com/contest.php?cid=1053),想来反正也没什么事,何不参加一下。于是晚上吃完饭回到实验室,等着七点开始做题。练习赛结束了,虽然自己全部AC,但感觉时间花的有点长,主要卡在第三道求公约数个数上。看来自己的数论真的弱爆了。现将自己对这四道解题的看法归纳一下,总的来说题目不算很难,前两道超级水,第三道考素数筛选以及因式分解,第四道动态规划。一、调整方阵对应题目1470:http://ac.jobdu.com/problem.php?pid=1470题目描述:输入一个N(N 2 3 int data[..
阅读全文
摘要:1021. Deepest Root (25)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 is called the deepest root. Input Specification: Each input file contains one
阅读全文
摘要:1019. General Palindromic Number (20)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.Although palindromic numbers are most often considered in the
阅读全文
摘要:1018. Public Bike Management (30)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.The Public Bike Management Center (PBMC) keeps monitoring the
阅读全文
摘要:1017. Queueing at Bank (25)Suppose 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 parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be served and there is a window available
阅读全文
摘要:1016. Phone Bills (25) A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the tim...
阅读全文
摘要:1015. Reversible Primes (20) 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 reverse 37 is also a prime. Now given any two positive integers N (#include...
阅读全文
摘要:1014. Waiting in Line (30) Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are: The space inside the yellow line in front of each window is eno...
阅读全文
摘要:1013. Battle Over Cities (25) 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 need to repair any other highways to keep the rest of ...
阅读全文
摘要:1012. The Best Rank (25) 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 Algrbra), and E - English. At the mean time, we encourage students by emphasiz...
阅读全文
摘要:1011. World Cup Betting (20) 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. Similarly, football betting fans were putting their mon...
阅读全文
摘要:1010. Radix (25) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N1 and N2, your task is to find the radix of one number wh...
阅读全文
摘要:1009. Product of Polynomials (25) This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, ...
阅读全文
摘要:1008. Elevator (20) 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 seconds to move the elevator up one floor, and 4 seconds to move d...
阅读全文
摘要:1007. Maximum Subsequence Sum (25) Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 23intmain()4{5intK;6intdata[10000];7inti;8intflag;9while(scanf("%d",&K)!=EOF){10flag=0;11for(i=0;i=0)14flag=1;15}16if(flag==0).
阅读全文
|