自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

NightWind

dreaming and chasing.

  • 博客(93)
  • 收藏
  • 关注

原创 Android RecyclerView 记录恢复滚动位置

新出的RecyclerView网上的资料比较少,根据ListView以及参考了一下官方API得出。定义两个成员变量:    private int lastPosition = 0;    private int lastOffset = 0;记录位置,OnScrollListener,onScrollStateChanged()里添加:           

2014-12-19 17:36:09 10379 1

原创 KMP算法笔记

#include #include using namespace std;int violentMatch(char *s, char *p){ int sLen = (int)strlen(s); int pLen = (int)strlen(p); int i = 0, j = 0; while (i < sLen && j < pLen)

2014-08-02 00:39:15 711

原创 POJ 1179 Polygon(动态规划:类似环形石子合并)

#include #include #include using namespace std;const int MAX_N = 51;const int INF = 0x3f3f3f3f;int n;int a[MAX_N * 2];char e[MAX_N * 2];int dMax[MAX_N * 2][MAX_N * 2];int dMin[MAX_N * 2][MAX

2014-06-18 14:09:15 1049

原创 最长不下降子序列(动态规划:LIS)

d[i] = int LIS(int a[], int n){ int d[1000]; memset(d, 0, sizeof(d)); for(int i = 0; i < n; i++) { d[i] = 1; for(int j = 0; j < i; j++) { if(a[i] >= a[j] && d[j]+1 > d[i]) {

2014-06-14 21:25:22 867

原创 石子合并问题(动态规划)

#include #include #include using namespace std;const int MAX_N = 101;const int INF = 0x3f3f3f3f;int n;int a[MAX_N];int d[MAX_N][MAX_N];int sum[MAX_N];void solve(){ //init sum[] sum[0] =

2014-06-14 21:19:42 1994

原创 POJ 1178 - Camelot (枚举+dp : floyd)

点击打开链接/************************************************************************poj 1178 (IOI 1998) - dp : floyd枚举64个终点 * 枚举64个接国王点 * 枚举64只来接的骑士总复杂度O(64*64*64)

2014-06-14 15:34:45 682

原创 POJ 1157 - LITTLE SHOP OF FLOWERS (动态规划)

点击打开链接W// poj 1157 (IOI 1999 - dp)// [6/13/2014 wind]#include #include using namespace std;int const MAX_N = 101, INF = 0x3f3f3f3f;int f, v;int a[MAX_N][MAX_N];int d[MAX_N][MAX_N];

2014-06-13 15:59:39 665

原创 POJ 1088 - 滑雪(动态规划)

点击打开链接// poj 1088// [6/11/2014 wind]#include #include #include using namespace std;const int MAX_RC = 100;int row, cow;int a[MAX_RC][MAX_RC];int d[MAX_RC][MAX_RC];int dx[] = { -1, 1

2014-06-11 21:22:30 544

原创 POJ - 1083 Moving Tables

//poj 1083// [6/11/2014 wind]#include #include #include #include using namespace std;const int MAX_N = 200;int n;int cdr1[MAX_N], cdr2[MAX_N];int cnt[MAX_N];void solve(){ memset ( cnt,

2014-06-11 20:10:06 623

原创 POJ 1050 To the Max(动态规划、最大子矩阵和)

//poj 1050 - dp//2014-6-11#include #include #include using namespace std;const int MAX_N = 111;int n;int a[MAX_N][MAX_N];//int d[MAX_N][MAX_N][MAX_N];int inline getMax ( int a, int b, int c

2014-06-11 13:36:01 749

转载 最大子段和

#includeint a[1000001]; int maxsum(int x[],int n);int main(){ int T,n,i; scanf("%d",&T); do { scanf("%d",&n); for(i = 0 ; i < n ; ++i) scanf("%

2014-06-11 11:37:05 731

原创 POJ 1018 Communication System(搜索/贪心/动归)

点击打开链接

2014-06-10 18:27:34 840

原创 vua 10282 - Babelfish(Hash、map)

点击打开链接题意:100000个字的

2014-05-27 22:54:25 592

原创 UVa10422 - Knights in FEN

题意:类似与八数码,不过限制了最大步数为10。用了DFS#include #include #include #include using namespace std;const int N = 5;int s[N][N];int ans;int dir[8][2] = { {-2, -1}, {-2, 1}, {-1, 2}, {1, 2}, {2, 1},

2014-05-27 20:44:13 603

原创 10160 - Servicing Stations(TLM)

DFS, TLM了,先放着……#include #include #include #include using namespace std;const int N = 35+1, M = N*N/2;int a[N][N];bool vis[N];int n, m, ans;void dfs(int buildNum, int cur, int nconn){ if(

2014-05-27 15:57:37 692

原创 167 - The Sultan's Successors(搜索:八皇后)

#include #include #include using namespace std;const int N = 8;int t, ans, tans;int a[N][N];int vis[3][N*2];int C[N*2];void dfs(int cur) { if(cur == N) ans = max(ans, tans); else for(in

2014-05-21 18:44:12 605

原创 331 - Mapping the Swaps(搜索)

点击打开链接刷点水题找找感觉。。。。

2014-05-21 17:19:36 678

原创 uva 539 - The Settlers of Catan(搜索)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_problem&problem=480#include #include #include using namespace std;const int MAX_N = 25;int n, m;in

2014-05-14 10:09:46 583

转载 py+pyqt4+Eric4安装配置

【配置环境】第一步:安装python包Python 下载 python官网: http://www.python.org/ 第二步:安装pyqt4pyqt4  官网:http://www.riverbankcomputing.co.uk/news下pyqt4的时候请对应你的py版本。下载对应版本的p

2014-05-12 19:20:59 798

原创 C语言SOCKET获取本机所有IP

void printHostIp(){ char hostName[255]; char *ip; PHOSTENT hostinfo; gethostname(hostName, sizeof(hostName)); hostinfo = gethostbyname(hostName); printf("Your all IP address are\n"); for(

2014-05-02 18:02:42 2018

原创 C语言使用socket通过IP138获取外网IP

WORD wVersionRequested; WSADATA wsaData; wVersionRequested = MAKEWORD( 1, 1 ); WSAStartup( wVersionRequested, &wsaData );void getNetIp(char *ip){ //创建连向服务器的套接字 SOCKET sock = socket(AF_INE

2014-05-02 18:01:14 2548

原创 uva 10474 - Where is the Marble?(排序,二分搜索)

#include #include #include using namespace std;const int MAX_N = 10000;int N, Q;int a[MAX_N+10];int main(){ //freopen("in.txt", "r", stdin); int t = 1; while(scanf("%d%d", &N, &Q), N+Q) {

2014-04-29 20:50:50 690

原创 uva 729 - The Hamming Distance Problem(全排列)

点击打开链接

2014-04-28 11:43:31 609

原创 uva 10098 - Generating Fast(全排列)

点击打开链接#include #include #include #include using namespace std;int T, n;char P[20];int main(){ //freopen("in.txt", "r" ,stdin); //freopen("out.txt", "w" ,stdout); scanf("%d", &T); w

2014-04-28 10:19:29 630

原创 生成全排列的一些方法

#include#include#includeusing namespace std;int n;int A[100];//int P[100] = {1, 2, 2, 4, 5, 6, 6, 8, 9, 10};//int P[100] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};char P[100];void print_subset(int n,

2014-04-28 09:56:31 629

转载 二进制法生成子集

#include#include#includeusing namespace std;int n;void print_subset(int n, int s){ for(int i = 0; i < n; i++) if(s & (1 << i)) printf("%d ", i); printf("\n");}void solve(){ for(int i

2014-04-27 21:38:23 816

转载 浅谈C++多态性

原文链接:http://blog.csdn.net/hackbuteer1/article/details/7475622        C++编程语言是一款应用广泛,支持多种程序设计的计算机编程语言。我们今天就会为大家详细介绍其中C++多态性的一些基本知识,以方便大家在学习过程中对此能够有一个充分的掌握。  多态性可以简单地概括为“一个接口,多种方法”,程序在运行时才决定调用的函数,它是

2014-04-27 11:32:31 533

原创 POJ - 3685 Matrix (二分搜索:查找第k大的值)

http://poj.org/problem?id=3685题意:定义一个矩阵:

2014-04-19 17:44:20 1023

原创 POJ - 3579 Median(二分搜索,查找第K大的值)

http://poj.org/problem?id=3685题意:

2014-04-18 19:55:57 1196

原创 POJ - 2976 Dropping tests(二分搜索:最大化平均值)

点击打开链接题意:

2014-04-11 17:30:01 821

原创 POJ - 3104 Drying (二分搜索)

http://poj.org/problem?id=3104题意:有N

2014-04-10 20:55:30 794

原创 POJ - 3273 Monthly Expense(二分搜索:最小化最大值)

http://poj.org/problem?id=3273#include #include using namespace std;const int MAX_N = 1e5, INF = 1e4 * MAX_N+1;int L, N, M;int a[MAX_N+10];bool C(int x){ int cnt = 0, sum = 0; for(int

2014-04-08 22:30:41 736

原创 POJ - 3258 River Hopscotch(二分搜索:最大化最小值)

Link题意:

2014-04-07 17:06:55 872

原创 求区间内随机值

int myrand(double a, double b){ return double(rand()) / RAND_MAX*(b - a) + a;}

2014-04-06 18:32:31 763

原创 最大化平均值

#include #include #include #include using namespace std; const int MAX_N = 10000, INF = 1000000+1;int N, K; int w[MAX_N], v[MAX_N];double y[MAX_N];bool C(double x){ for(int i

2014-04-06 18:30:53 750

原创 POJ - 2456 Aggressive cows(二分搜索:最大化最小值)

http://poj.org/problem?id=2456

2014-04-06 15:25:44 759

原创 POJ - Cable master (二分搜索)

有N条绳子,他们的长度分别是Li。如果从他们中切割出K条长度相同的绳子的话,这K条

2014-04-06 15:20:31 1230

原创 二分搜索:lower_bound, upper_bound

#include #include using namespace std; const int MAX_N = 100; int N, M; int a[MAX_N] = {2, 3, 3, 5, 6};int lower_bound(int a[], int n, int key){ int l = 0, r = n; while(r > l) { int

2014-04-04 17:08:50 745

原创 最短路总结:Dijkstra,SFPA,Bellman Ford判负环,Floyd

Dijkstra:贪心思想:1、找到最短距离已经确定的顶点,从它出发更新相邻顶点的最短距离。2、此后不需要再关心1中的“最短距离已确定的顶点”。优先队列优化:在队列中取出d值最小的结点x,然后从x出发更新所有的边的d值。初始化:first[u]  结点u的第一条边next[i] 边i的下一条边d -> INF时间复杂度O(elogv)#include

2014-03-21 16:13:25 1986

原创 UVA - 624 - CD(动态规划,背包,打印路径)

点击打开链接题意:储存空间为N,有T首个,要求尽可能的填满储存空间,输出存放的歌曲和总的占用空间。分析:01背包,打印路径。#include #include #include using namespace std;const int MAX_N = 100000, MAX_M = 21, INF = 0x3f3f3f3f;int N, T;int a[MAX_M];i

2014-03-13 15:47:06 940

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除