码迷,mamicode.com
首页 >  
搜索关键字:combination sum ii    ( 27716个结果
杭电2014
1 #include 2 #include 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 double max,min,sum,aver; 9 double a[110] = {0};10 while...
分类:其他好文   时间:2014-05-16 22:47:35    阅读次数:452
lightoj 1427 - Substring Frequency (II) AC自动机
模板题,找来测代码。注意有相同单词//#pragma comment(linker, "/STACK:1024000000,1024000000")#include#include#include#include#include#include#include#include#include#inc...
分类:其他好文   时间:2014-05-16 05:45:11    阅读次数:403
sum max(hdu 1003)
观察可以发现,0,1,2,……,n结尾的分组中,maxsum a[0] = a[0]maxsum a[1] = max( a[0] + a[1] ,a[1]) = max( maxsum a[0] + a[1] ,a[1])maxsum a[2] = max( max ( a[0] + a[1] +...
分类:其他好文   时间:2014-05-14 08:38:58    阅读次数:323
LeetCode---Remove Duplicates from Sorted List II
题目链接题意: 给出单链表的head指针, 要求去除链表中所有出现重复的元素, 如1->2->3->3->4->4->5, 返回1->2->5这题纠结了有两天, 重要的是把思路想清楚然后就可以痛苦的A掉, 不然老是会绕来绕去...我的大体思路是这样的: 使用三个指针 pre保存链表中前一个没有出现重...
分类:其他好文   时间:2014-05-13 18:54:51    阅读次数:237
【LeetCode】Triangle
TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given...
分类:其他好文   时间:2014-05-13 18:51:44    阅读次数:297
UVA 1350 - Pinary(数论+递推)
题目链接:1350 - Pinary 题意:二进制数,不能有连续的1,给定第n个数字,输出相应的二进制数 思路:先是递推,求出由n位组成的数字中有几个满足条件 dp[i] = dp[i - 1] + dp[i - 2],考虑最后一位放0和倒1位放0的情况。 然后用一个sum[i]记录满足 接着利用二分找到给定的n > sum[i - 1],i的最大值,这个就是所求的答案的最高位。 因为...
分类:其他好文   时间:2014-05-13 14:10:44    阅读次数:246
Leetcode 贪心 Best Time to Buy and Sell StockII
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie Best Time to Buy and Sell Stock II  Total Accepted: 13030 Total Submissions: 36467 Say you have an array for which the ith ...
分类:其他好文   时间:2014-05-13 14:08:39    阅读次数:414
POJ2480 Longge's problem 欧拉函数的应用 && 积性函数
题意很简单,求sum(gcd(i,n))   1 这题看到后第一反应并没有里用积性函数的性质,不过也可以做,欣慰的是我反应还是比较快的 设f(n)=gcd(1,n)+gcd(2,n)+....+gcd(n-1,n) + gcd(n,n), 用g(n,i)表示满足 gcd(x,n)=i的 x的个数 (x小于n),则 f(n)=sum{i*g(n,i)}; 同时又利用 扩展欧几里德的性...
分类:其他好文   时间:2014-05-13 13:40:58    阅读次数:365
[ACM] 1016 Prime Ring Problem (深度优先搜索)
Prime Ring Problem Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent...
分类:其他好文   时间:2014-05-13 11:54:17    阅读次数:444
hdu 3415 单调队列
Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5690    Accepted Submission(s): 2059 Problem Description ...
分类:其他好文   时间:2014-05-13 11:38:49    阅读次数:256
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!