码迷,mamicode.com
首页 >  
搜索关键字:number of islands    ( 27069个结果
Codeforces 464C Substitutes in Number(高效+快速幂)
题目链接:Codeforces 464C Substitutes in Number 题目大意:给定一个字符串,以及n中变换操作,将一个数字变成一个字符串,可能为空串,然后最后将字符串当成一 个数,取模1e9+7。 解题思路:将操作倒过来处理,这样维护每个数来的val,len两个,val表示对应数值取模1e9+7,len表示对应有多少 位,再计算的过程中要使用。 #inc...
分类:其他好文   时间:2014-09-09 13:13:48    阅读次数:197
Leetcode dfs Letter Combinations of a Phone Number
Letter Combinations of a Phone Number  Total Accepted: 15964 Total Submissions: 60700My Submissions Given a digit string, return all possible letter combinations that the number could repr...
分类:其他好文   时间:2014-09-09 13:13:39    阅读次数:191
Codeforces 464 C. Substitutes in Number 动态规划法题解
本题使用动态规划法思想。 因为需要一步一步地替换相对应的数字的,如果直接模拟,那么就需要大量插入和删除操作,最快也需要lg(n)的效率,但是最后数列就会变得非常长,这样最后计算结果遍历一次也会超时的。故此使用数据结构加速替换操作,并不是好办法。 这就使用动态规划法从后往前替换,相当于路径压缩了,一步直接把数字替换成最终结果的数字。 也要记录好每个数字最终替换成多少个数位,以便正确计算结果。 可以画树来模拟一下替换操作,那么从叶子节点往根节点替换数字,把所有的路径都直接压缩起来。...
分类:其他好文   时间:2014-09-09 13:11:48    阅读次数:259
LeetCode 第九题, Palindrome Number
题目原文: Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of conv...
分类:其他好文   时间:2014-09-09 13:04:18    阅读次数:156
Letter Combinations of a Phone Number
[leetcode]Letter Combinations of a Phone Number...
分类:其他好文   时间:2014-09-09 12:49:58    阅读次数:224
Valid Number
[letcode]Valid Number...
分类:其他好文   时间:2014-09-09 12:49:48    阅读次数:143
HDU 1018 Big Number
题意:给你一个数,计算他的阶乘有多少位。 算阶乘再看位数必超时。1 想每次%10 。一开始用int 果然有精度问题。于是double水了。600+ms 后来想到可以 log 10 () 。于是900+ms。 总觉得不对。应该有公式。看discuss 后终于知道了。 #include #include #include #include #inclu...
分类:其他好文   时间:2014-09-09 12:37:18    阅读次数:165
perl实现从一个文件中随机抽取n行
if(@ARGV!=2){   die "Usage: $0 sample_file sample_number\n"; } my($sample_file, $sample_number) = @ARGV; open my $FILE, " my @content = ; my $all_number = @content; #print "|$all_number|\n";...
分类:其他好文   时间:2014-09-09 12:33:48    阅读次数:351
Hypervisor, computer system, and virtual processor scheduling method
Ahypervisorcalculates the total number of processor cycles (the number of processor cycles of one or more physical processors) in a first length of ti...
分类:其他好文   时间:2014-09-09 11:47:48    阅读次数:320
ZOJ - 3816 Generalized Palindromic Number dfs
Generalized Palindromic NumberTime Limit: 2 Seconds Memory Limit: 65536 KBA number that will be the same when it is written forwards or backwards i...
分类:其他好文   时间:2014-09-09 11:19:48    阅读次数:351
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!