#include
#include
#include
#include
using namespace std;
const int N = 25;
char map[N][N];
int vis[N][N][1<<11];
struct Node
{
int x,y,step;
int key;
};
int dx[6]={0,0,1,-1};
int dy[6]={1,-...
分类:
其他好文 时间:
2014-08-30 12:39:39
阅读次数:
196
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder it to ...
分类:
其他好文 时间:
2014-08-30 00:06:58
阅读次数:
359
Sort a linked list using insertion sort.
【题意】
用插入排序对一个链表进行排序。
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
...
分类:
其他好文 时间:
2014-08-29 21:26:48
阅读次数:
233
”感知哈希算法”(Perceptual hash algorithm),它的作用是对每张图片生成一个”指纹”(fingerprint)字符串,然后比较不同图片的指纹。结果越接近,就说明图片越相似。优点:简单快速,不受图片大小缩放的影响。缺点:图片的内容不能更改。主要用途:根据缩略图找出原图,搜索.....
分类:
其他好文 时间:
2014-08-29 17:39:28
阅读次数:
239
MD5加密算法 算法简介 MD5的全称是Message-Digest Algorithm 5(信息-摘要算法),在90年代初由Mit Laboratory for Computer Science和Rsa data security inc的Ronald l. rivest开发出来,经md2、md3和md4发展而来...
题目:
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only cons...
分类:
其他好文 时间:
2014-08-29 13:13:37
阅读次数:
169
STL中简单算法实例sort()、next_permutation()#include<iostream>
#include<string>
#include<algorithm>
usingnamespacestd;
intmain()
{
stringletters;
cout<<"Enterthelettersgrouping(quittoquit):";
while(cin>>letters&&letter..
分类:
其他好文 时间:
2014-08-29 03:03:17
阅读次数:
242
Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp...
分类:
其他好文 时间:
2014-08-29 01:18:36
阅读次数:
275
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3629
思路:找规律,发现符合要求的数为
[0,1)
[4,9)
[16,25)
[36,49)
…………
[n^2 , (n+1)^2)
发现 n^2 到(n+1)^2(n为偶数)前开后闭的区间为符合要求的数,然后发现(n+1)*(n+1)-n*n...
分类:
其他好文 时间:
2014-08-28 22:49:06
阅读次数:
311
【题意】
求二维平面上n个点中,最多共线的点数。
【思路】
比较直观的方法是,三层循环,以任意两点划线,判断第三个点是否在这条直线上。
【Java代码】
/**
* Definition for a point.
* class Point {
* int x;
* int y;
* Point() { x = 0; y = 0; }
* Po...
分类:
其他好文 时间:
2014-08-28 22:44:36
阅读次数:
248