Sum square difference
Problem 6
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ....
分类:
其他好文 时间:
2014-05-23 02:22:57
阅读次数:
193
题目链接:hdu 4825 Xor Sum
题目大意:中文题。
解题思路:将给定得数按照二进制建成一颗字典树,每一层分别对应的各个位数上的01状态。然后每一次查询,如果对应位置为0,则要往1的方向走,如果是1,则要往0的方向走。但是要注意,走的前提是对应分支是存在的。
#include
#include
#include
using namespace std;
//type...
分类:
其他好文 时间:
2014-05-23 02:15:15
阅读次数:
286
同样是查找一个图是否有环的算法,但是这个算法很牛逼,构造树的时候可以达到O(lgn)时间效率。n代表顶点数
原因是根据需要缩减了树的高度,也叫压缩路径(Path compression),名字很高深,不过其实不难理解,简单来说就是每次查找一个节点的时候,都把这一路径中的所有节点都赋予根节点作为路径。
原文没指出的地方:
也因为需要压缩,所以初始化的时候注意,不能如前面简单实用Unio...
分类:
其他好文 时间:
2014-05-23 00:21:42
阅读次数:
305
话不多少,直接上代码,思路还是挺简单的。
UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.frame];
// HTML文件来自Project
// 步骤:path - > url - > request with url - > loadRequest
NSStrin...
分类:
编程语言 时间:
2014-05-22 23:53:05
阅读次数:
442
刷了这么长时间POJ了 可算看到了一个中文题,不容易啊~~。
题目大意:自己看。
解题思路:
dp[x1][y1][x2][y2][num]代表从(x1,y1)到(x2,y2)分成num+1块最小的平方和是多少。
下面是代码:
#include
#include
#include
int sum[10][10],board[10][10];
d...
分类:
其他好文 时间:
2014-05-22 23:06:07
阅读次数:
300
今天在做图片上传 验证图片mime值时 突然发现 个别特殊情况下finfo_file 获取的MIME值不能直接使用,按照官方的写法是 $finfo=finfo_open(FILEINFO_MIME); $mime=finfo_file($finfo,$file_path); finfo_close($finfo); alert($mime);这样子获得文件mime类型的但是今天发现这样子...
分类:
其他好文 时间:
2014-05-22 22:37:21
阅读次数:
443
【题目】
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is to reach the last index in the minimum number of ju...
分类:
其他好文 时间:
2014-05-22 17:02:20
阅读次数:
244
Given an arraySofnintegers, are there
elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which
gives the sum of zero.Note:Elemen...
分类:
其他好文 时间:
2014-05-22 16:53:52
阅读次数:
173
Given a binary tree, find its maximum depth.The
maximum depth is the number of nodes along the longest path from the root node
down to the farthest le...
分类:
其他好文 时间:
2014-05-22 16:05:56
阅读次数:
239
Max Sum Plus PlusTime Limit: 2000/1000 MS
(Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s):
15817Accepted Submission(s): 5140...
分类:
其他好文 时间:
2014-05-22 14:06:42
阅读次数:
250