
ACM算法
文章平均质量分 68
sysu_strange
诗和远方
展开
-
Root of the Problem
DescriptionGiven positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equ原创 2015-08-26 21:42:26 · 541 阅读 · 0 评论 -
【面试真题】给定长度为n的数组,内部有n-2个整数出现了偶数次,和2个只出现奇数次的整数,找到这两个数
这是一道网络上流传的微软电面的真题,题目内容已经讲述在标题:在O(1)的内存上,找到这两个只出现奇数次的整数。解决的主要方法是使用异或运算,我们知道异或的性质有:1)a^a=0;2)0^b=b;因此,当数组中所有的数字都互相做异或的时候,那么最后得到的结果,其实就是这两个只出现奇数次的整数异或后的结果。我们假设这个结果为001001。首先因为这两个数肯定不相等,所以结果中总原创 2017-02-26 21:25:17 · 1178 阅读 · 0 评论 -
Phone number - Multiway Trees
Phone number Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:原创 2015-12-28 11:33:17 · 495 阅读 · 0 评论 -
heap
1002. heap 实现一个小根堆用以做优先队列。给定如下数据类型的定义:class array { private: int elem[MAXN]; public: int &operator[](int i) { return elem[i]; }};class heap { private:原创 2015-11-25 16:51:02 · 459 阅读 · 0 评论 -
Find the k-th smallest element
1001. Find the k-th smallest element Given a sequence A=(a1,...,an), your job is to find the (k+1)-th smallest element of A.For example, A=(3, 2, 3, 4, 5) and k=1, then 3 is returned, sinc原创 2015-11-25 16:48:54 · 825 阅读 · 0 评论 -
message_flood
1194. Message FloodConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionWell, how do you feel about mobile phone? Your answer would probably be something like that “It’s so conven原创 2015-09-21 20:34:51 · 365 阅读 · 0 评论 -
PRIME
1561. PRIMEConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. The first pr原创 2015-10-08 16:48:00 · 322 阅读 · 0 评论 -
Alice and Bob
1798. Alice and BobConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionBob is very famous because he likes to play games. Today he puts a chessboard in the desktop, and plays a g原创 2015-09-17 21:57:18 · 666 阅读 · 0 评论 -
笨猴子
1765. 笨小猴ConstraintsTime Limit: 1 secs, Memory Limit: 32 MB Description笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼。但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大!这种方法的具体描述如下:假设maxn是单词中出现次数最多的字母的出现次数,minn是单词中出现次原创 2015-09-17 22:43:18 · 625 阅读 · 0 评论 -
The hardest problem
DescriptionIn the final exam, you are given n problems to solve, each one of which has an integer value indicating its difficulty, the larger, the harder. You need to find out which problem is the h原创 2015-08-21 22:40:19 · 557 阅读 · 1 评论 -
Biker's Trip Odomete
DescriptionMost bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A magnet is attached to one of the spokes on the front wheel so that it will line u原创 2015-08-21 22:14:58 · 455 阅读 · 1 评论 -
解码
1753. 解码ConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionZX是另一头04级的牛,他现在在UPen。他跟LLK经常通信,但他不喜欢直接把信息发给LLK,而是把信息通过一个规则转换后再发给LLK,这让LLK很郁闷。他的规则如下:如果字符x出现的n次,则将这几个连在一起的字符表示为xn,例如aaa->原创 2015-09-26 11:26:09 · 512 阅读 · 0 评论 -
Stick
1200. StickConstraintsTime Limit: 1 secs, Memory Limit: 32 MB Description Anthony has collected a large amount of sticks for manufacturing chopsticks. In order to simplify his job, he want原创 2015-09-26 11:24:27 · 433 阅读 · 0 评论 -
简单魔板[Special judge]
Description魔板由8个大小相同方块组成,分别用涂上不同颜色,用1到8的数字表示。其初始状态是1 2 3 48 7 6 5对魔板可进行三种基本操作:A操作(上下行互换):8 7 6 51 2 3 4B操作(每次以行循环右移一个):4 1 2 35 8 7 6C操作(中间四小块顺时针转一格):1 7 2 48 6 3 5用上述三原创 2015-08-29 19:53:10 · 561 阅读 · 0 评论 -
Show me the money
DescriptionFakosh like playing the game "StarCraft". However, he is not so good at this game that he can't beat the AI. For victory, he typed "show me the money" to cheat, and then he would get som原创 2015-08-26 21:40:26 · 640 阅读 · 0 评论