题目大意:
给你N个正数的序列,从中找到连续的若干数,使得其和刚好是N的倍数。
解题思路:
典型的抽屉原理。
Sum[i]为序列中前i项的和。则有两种可能:
1.若有Sum[i]是N的倍数,则直接输出前i项。
2.如果没有任何的Sum[i]是N的倍数,则计算ri = Sum[i] % N。根据鸽巢原理,肯
定有Sum[i] % N == Sum[j] % N,i != j。则第 j 到第 i 项数的和即为N的倍数。...
分类:
其他好文 时间:
2015-08-18 14:19:03
阅读次数:
117
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2015-08-18 13:48:33
阅读次数:
106
题目:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complet...
分类:
其他好文 时间:
2015-08-18 11:39:48
阅读次数:
190
Problem DescriptionXX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的通道P 的安全度为Safe(P) = s(e1)*s(e2)…*s(ek) e1,e2...
分类:
其他好文 时间:
2015-08-18 10:14:03
阅读次数:
98
Problem Description:You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its i...
分类:
其他好文 时间:
2015-08-18 09:04:26
阅读次数:
100
【136-Single Number(只出现一次的数字)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a...
分类:
编程语言 时间:
2015-08-18 07:57:37
阅读次数:
233
【137-Single Number II(只出现一次的数字II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm sh...
分类:
编程语言 时间:
2015-08-18 07:56:07
阅读次数:
249
grep常用的使用方法 grep –rns “match_content”filename 查看匹配内容的行 find /path –name “*.h” –o –name “*.cpp” | xargs grep –rn “match_content”在特定的文件类型中查找 grep –rns “...
分类:
其他好文 时间:
2015-08-18 07:55:08
阅读次数:
1097
远程路由访问我配置了很久都不成功,经过多方搜索,现面的命令能实现端口映射一、查询端口映射情况netsh interface portproxy show v4tov4查询这个IP所有的端口映射。netsh interface portproxy show v4tov4|find "192.168.1...
分类:
其他好文 时间:
2015-08-18 06:31:16
阅读次数:
314
求n以内能够被所给的集合中的数整除的数的个数。...
分类:
其他好文 时间:
2015-08-18 01:21:19
阅读次数:
118