码迷,mamicode.com
首页 >  
搜索关键字:codevs 1503 愚蠢的宠物 解题报告    ( 3864个结果
BestCoder15 1002.Instruction(hdu 5083) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5083题目意思:如果给出 instruction 就需要输出对应的16-bit binary code,给出16-bit binary code 就需要输出对应的instruction。 由于不会截取的....
分类:其他好文   时间:2014-10-27 00:15:41    阅读次数:354
LeetCode: Add Binary 解题报告
Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".SOLUTION:指针指到两个字符串的末尾,不断往前推进,用carr...
分类:其他好文   时间:2014-10-26 22:40:47    阅读次数:339
LeetCode: Valid Parentheses 解题报告
Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets m...
分类:其他好文   时间:2014-10-26 22:31:27    阅读次数:438
LeetCode: Merge Intervals 解题报告
Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,1...
分类:其他好文   时间:2014-10-26 21:04:46    阅读次数:199
【动态规划】【记忆化搜索】【搜索】CODEVS 1262 不要把球传我 2012年CCC加拿大高中生信息学奥赛
可以暴力递归求解,应该不会TLE,但是我们考虑记忆化优化。设f(i,j)表示第i个数为j时的方案数。f(i,j)=f(1,j-1)+f(2,j-1)+……+f(i-1,j-1) (4>=j>=1),从f(n,4)开始递归求解就行。但是考虑到状态最多只有n*4种,所以记忆化掉吧。初始化:f(i,1)=...
分类:其他好文   时间:2014-10-26 19:35:09    阅读次数:183
【动态规划】【记忆化搜索】CODEVS 1011 数的计算 2001年NOIP全国联赛普及组
设答案为f(n),我们显然可以暴力地递归求解:f(n)=f(1)+f(2)+……+f(n/2)。但是n=1000,显然会超时。考虑状态最多可能会有n种,经过大量的重复计算,所以可以记忆下来,减少不必要的计算。 1 #include 2 using namespace std; 3 int n; 4 ...
分类:其他好文   时间:2014-10-26 18:20:58    阅读次数:295
【数论】【最大公约数】【枚举约数】CODEVS 1012 最大公约数和最小公倍数问题 2001年NOIP全国联赛普及组
对于一对数(p,q),若它们的gcd为x0,lcm为y0,则:p*q/x0=y0,即q=x0*y0/p,由于p、q是正整数,所以p、q都必须是x0*y0的约数。所以O(sqrt(x0*y0))地枚举约数,依次用gcd判断。 1 #include 2 #include 3 using namespac...
分类:其他好文   时间:2014-10-26 18:12:47    阅读次数:231
【LeetCode】ZigZag Conversion 解题报告
【题目】 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N ...
分类:其他好文   时间:2014-10-26 16:57:47    阅读次数:182
【LeetCode】Longest Palindromic Substring 解题报告
DP、KMP什么的都太高大上了,自己想了个朴素的遍历方法。 【题目】 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palin...
分类:其他好文   时间:2014-10-26 15:37:32    阅读次数:249
【LeetCode】Add Two Numbers 解题报告
【题目】 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it...
分类:其他好文   时间:2014-10-26 14:21:29    阅读次数:243
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!