百度之星2015资格赛#1003 IP聚合Accepts: 2204 Submissions: 5861Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem Description当今世界,网络已经无处不在了,小度熊由于犯了错误,当上了度度公司的网络管理员,他手上有大量的 IP列表,小度熊想知道
百度之星2015资格赛#1001 大搬家Accepts: 1428 Submissions: 5901Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem Description近期B厂组织了一次大搬家,所有人都要按照指示换到指定的座位上。指示的内容是坐在位置i上的人要搬到位置j上。现在B厂有N
百度之星2015资格赛#1002 列变位法解密Accepts: 1233 Submissions: 4720 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Problem Description列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥
Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB 思路:依旧是进制转换类型的,由于不是从0开始的 我
Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element al
Excel Sheet Column Number Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA ->
Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.思路:大意是求n!的末尾有多少个0,可以想到要在末尾产生0,就必须有10才行,10=5*2,在阶乘中不缺2,那么这个问题就变成了在这
Rotate Array Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as you
Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000
Reverse Bits Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010
House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house
Happy Number Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
Remove Nth Node From End of List Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the l
Count and Say The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one
hihoCoder hiho一下 第四十四周 博弈游戏·Nim游戏 题目1 : 博弈游戏·Nim游戏时间限制:10000ms单点时限:1000ms内存限制:256MB描述今天我们要认识一对新朋友,Alice与Bob。Alice与Bob总是在进行各种各样的比试,今天他们在玩一个取石子的游戏。在这个游戏中,Alice和Bob放置了N堆不同的石子,编号1..N,第i堆中有A[i]个石子。每一次行动,Alice和Bob可以选择从一堆石子
自用矩阵操作 #ifndef _MATRIX_H_#define _MATRIX_H_#define T 8#includeclass Matrix{public: Matrix(); Matrix operator *(Matrix &m); Matrix operator %(int mod); int getAns(int c, int r); void setAns(int c, i
hihoCoder hiho一下 第四十二周:骨牌覆盖问题·二 题目1 : 骨牌覆盖问题·二时间限制:10000ms单点时限:1000ms内存限制:256MB描述上一周我们研究了2xN的骨牌问题,这一周我们不妨加大一下难度,研究一下3xN的骨牌问题?所以我们的题目是:对于3xN的棋盘,使用1x2的骨牌去覆盖一共有多少种不同的覆盖方法呢?首先我们可以肯定,奇数长度一定是没有办法覆盖的;对于偶数长度,比如2,4,我们有下面几种覆盖方
编程之美2015资格赛#3 题目3 : 基站选址时间限制:2000ms单点时限:1000ms内存限制:256MB描述需要在一个N × M的网格中建立一个通讯基站,通讯基站仅必须建立在格点上。网格中有A个用户,每个用户的通讯代价是用户到基站欧几里得距离的平方。网格中还有B个通讯公司,维护基站的代价是基站到最近的一个通讯公司的路程(路程定义为曼哈顿距离)。在网格中建立基站的总代价是用户
编程之美2015资格赛#2 题目2 : 回文字符序列时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为"a", "a", "aa", "b", "aba",共5个。内容相同位置不同的子序列算不同的子序列。输入第一行一个整数T,表示数据组数。之后是T组数据,每组数据为一行