- 博客(63)
- 资源 (1)
- 收藏
- 关注
原创 +load和+initialize笔记
+initialize+ (void)initialize 消息是在该类接收到其第一个消息之前调用。关于这里的第一个消息需要特别说明一下,对于 NSObject 的 runtime 机制而言,其在调用 NSObject 的 + (void)load 消息不被视为第一个消息,但是,如果像普通函数调用一样直接调用 NSObject 的 + (void)load 消息,则会引起 + (void)init
2017-03-22 16:50:12
474
转载 Mac 基本命令
ls 参数 目录名例: 想看看根目录下有什么, ls / 想看看驱动目录下有什么,ls /System/Library/Extensions 参数 -w 显示中文,-l 详细信息, -a 包括隐藏文件转换目录 cd 例:想到驱动目录下溜达一圈 cd /System/Library/Extensions建立新目录 mkdir 目录名 例:在驱动目录
2013-11-06 13:53:03
691
转载 Eclipse开发Android的配置-ADT安装,SDK配置
1. 下载Android SDK http://code.google.com/android/download.html下载后直接解压就可以使用了。 为了在DOS控制台中直接使用SDK的工具,可以将SDK的目录添加到Windows的path环境变量中: 在桌面上右击“我的电脑”,依次点击【属性】>【高级】>【环境变量】。 双击【系统变量
2013-10-29 21:07:22
1059
转载 stl string常用函数
string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常stri
2013-10-21 19:47:44
609
原创 cf-348A 二分暴力
http://codeforces.com/problemset/problem/348/A由题意直接对答案进行二分查找 知道找到满足条件的最小的answa了一次 是因为没有对数组排序#include #include #include #include #include #include using namespace std;#define MAX 10001
2013-10-01 00:00:50
1228
原创 hdu-4764 博弈
http://acm.hdu.edu.cn/showproblem.php?pid=4764由题意可知胜的一方必须是拿到N-1这个数 那么输的一方肯定是在 N-k-1 ~ N-2 这些数中取 那么赢的一方必然取到了N-k-2这个数所以一次递归推算 先手取到这些特殊数的必赢 这些数为 N-1、N-1-(k+1)、N-1-2(k+1) ......所以得如果N-1 能够整除 k+
2013-09-28 21:08:00
1536
原创 hdu-4762 大数处理 数学公式
http://acm.hdu.edu.cn/showproblem.php?pid=4762公式为 N/(M^(N-1))有了以前的模板大数类模板直接改main函数就行、约分int main(){ BigNum a,b; int M,N; int T; scanf("%d",&T); while(T--) {
2013-09-28 20:52:40
1520
原创 hdu-4763 kmp next数组的应用
http://acm.hdu.edu.cn/showproblem.php?pid=4763求最长的三个不重叠公共前缀,要求EAEBE的格式 即要求第一个在字符串开头 第三个在末尾 中间不能和首尾重叠刚开始就往后缀数组想 想了好久发现时间复杂度不可能呀 然后就想起了以前poj上水过的一题http://blog.youkuaiyun.com/fire_cat11211022/article
2013-09-28 20:45:16
1580
转载 asp.net 生成漂亮的验证码
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; u
2013-09-03 01:17:28
968
原创 poj-2777 线段树lazy标记+位运算
题目来源:http://poj.org/problem?id=2777题目意思很好懂 就是求解一段区间不同的数字的个数由于数字的种类小于30所以可以用位运算来代表不同的种类 纠结了好久开始一直TLE后来才改的位运算然后用到的就是区间的覆盖问题了#include #include #include #define MAX 100010using namespace
2013-08-30 23:56:00
644
转载 位运算总结
位运算应用口诀和实例位运算应用口诀 清零取反要用与,某位置一可用或若要取反和交换,轻轻松松用异或移位运算要点 1 它们都是双目运算符,两个运算分量都是整形,结果也是整形。 2 " 3 ">>"右移:右边的位被挤掉。对于左边移出的空位,如果是正数则空位补0,若为负数,可能补0或补1,这取决于所用的计算机系统。 4 ">>>"运算符,右边
2013-08-29 01:22:16
742
原创 poj-3261 后缀数组求可重叠的k次最长重复子串
http://poj.org/problem?id=3261根据http://blog.youkuaiyun.com/taceo/article/details/9908545论文由于数据比较大 先离散化求出height数组在二分字符串的长度求解 把height数组分组 看是否存在一组中 存在height[i]大于length k次的 然后进一步求解#include#include
2013-08-25 17:05:15
910
原创 hdu-4704 (a^b)%c
http://acm.hdu.edu.cn/showproblem.php?pid=4704求解(a^b)%c#include#include#include#include#define LL long long#define nnum 1000005#define nmax 31625int flag[nmax], prime[nmax];int plen;void
2013-08-24 12:44:30
1076
原创 hdu-1316 大数类模板
http://acm.hdu.edu.cn/showproblem.php?pid=1316包括大数的加减乘数 比较大小 取模 次方 输入输出 等的重载#include#include#include#include #include #includeusing namespace std;#define MAXN 9999#define MAXSIZE 100#def
2013-08-23 14:03:38
978
1
转载 数据的离散化 STL用法
有些数据本身很大, 自身无法作为数组的下标保存对应的属性。如果这时只是需要这堆数据的相对属性, 那么可以对其进行离散化处理!离散化:当数据只与它们之间的相对大小有关,而与具体是多少无关时,可以进行离散化。例如9 1 0 5 4 与 5 2 1 4 3 的逆序对个数相同。设有4个数:1234567、123456789、12345678、1234
2013-08-21 22:04:52
1277
2
原创 后缀数组 模板
搞了一下午才把后缀数组稍微明白了点 真是弱呀~~根据网上各种大神的模板 找了一份自己好看的留着以后用....#include #include const int maxn =200010;char s[maxn];int n;int st[maxn],sa[maxn],rank[maxn],height[maxn],wa[maxn],wb[maxn],ws[maxn
2013-08-21 17:17:56
883
原创 hdu-4691 最长公共前缀-后缀数组
http://acm.hdu.edu.cn/showproblem.php?pid=4691解析:当然用后缀数组最方便,在后缀数组中有很多重要的定义和性质,现在我们来认识一些:定义:LCP(i,j)=suffix(SA[i])与suffix[SA[j]]的最长公共前缀长度,即排号序后的后缀中第i名和第j名的最长公共前缀长度。然后我们再用一个重要的性质就可以求出LCP(i,j)了,性
2013-08-20 21:58:02
1395
原创 hdu-1166 敌兵布阵
http://acm.hdu.edu.cn/showproblem.php?pid=1166单点更新 区间求和 睡前一水~#include #include #include #include #include #include using namespace std;#define MAX 50010typedef struct{ int l;
2013-08-20 01:50:42
662
原创 hdu-1754 I Hate It 线段树
http://acm.hdu.edu.cn/showproblem.php?pid=1754求区间最大数,并且有单点操作#include #include #include #include #include #include using namespace std;#define MAX 200010typedef struct{ int l; int
2013-08-20 00:03:19
673
原创 hdu-1556 线段树
http://acm.hdu.edu.cn/showproblem.php?pid=1556可以说这是线段树的水题了么...注意输出格式 最后没有空格#include #include #include #define MAX 100010using namespace std;typedef struct{ int l; int r; int
2013-08-19 22:30:22
609
原创 poj-1067 威佐夫博奕 Wythoff Game
http://poj.org/problem?id=1067很明显不懂 直接看了discuss~ 先留着#include #include int ak, bk;double x;int main() { x = (1 + sqrt(5.0)) / 2; while(scanf("%d %d", &ak, &bk) != EOF) { i
2013-08-19 15:54:57
747
原创 poj-1013 Counterfeit Dollar
http://poj.org/problem?id=1013题目要求找出轻的或重的硬币#include #include #include #include using namespace std;#define MAX 1000000int ans[13];char rright[12],lleft[12],re[5];void findx(char str1[],cha
2013-08-19 14:40:08
757
原创 poj-1012 Joseph
http://poj.org/problem?id=1012记得这事刚学数据结构链表的经典题目水过题数吧~#include#include using namespace std;int J[14];int k;void init(){ for(int k=1; k<14; k++) { int n=2*k; int ans[
2013-08-19 00:17:39
730
原创 poj-1700 Crossing River
http://poj.org/problem?id=1700此题讲的是N个人过河,每个人都有自己的过河时间,一条船只能承受2个人,所用时间为其中过河时间最多的,所以呢,想到有两种情况,第一种:过河时间最少的人来回接送其他人,第二种:过河时间最少和次少的人来回接送其他人,刚开始就觉得第一种时间必然是最少的,但是仔细想想,不然。因为第一种情况虽然单次过河时间少,但送人的次数要多,如第1个人(过河时
2013-08-18 19:22:44
817
原创 poj-1338Ugly Numbers
http://poj.org/problem?id=1338DP 一步一步累乘上去 用三个标记比较大小就行#include#includeusing namespace std;long long a[1501];int n;void read(){ int i,j,k; int a1=1,a2=1,a3=1; a[1]=1; a1=1;
2013-08-18 15:59:47
716
原创 cf-337C Quiz
题目来源:http://codeforces.com/problemset/problem/337/C意思是给你n,m,k ;一共有n道题目 你能回答出m道题 每当你连续答对k道 你的分数就翻倍求你能得到的最小分数贪心 把翻倍的分数尽量放在前面然后就数学计算了 #include #include #include #include #include
2013-08-18 01:28:11
1048
原创 poj-3051 Satellite Photographs
题目来源:http://poj.org/problem?id=3051直接广度搜索 水~ 练手#include #include #include using namespace std;typedef struct{ int i; int j;}point;point P[80010];int W,H;char a[1010][90];int bf
2013-08-17 11:59:04
913
原创 poj-3045 Cow Acrobats
题目链接:http://poj.org/problem?id=3045按weight+strength 排序就行了#include #include #include using namespace std;typedef struct{ int weight; int stregth;} COW;COW cow[50010];int n;int cm
2013-08-17 11:21:24
1370
原创 poj-1200 Crazy Search
题目来源:http://poj.org/problem?id=1200遍历一遍 主要是判重 用到hash 不是很难 水~#include #include #include #include #define NUM 257#define N 16000005using namespace std;bool hash[N];int m[NUM];char s
2013-08-16 23:52:51
1144
原创 poj-2601Simple calculations
题目来源:http://poj.org/problem?id=2601给你公式ai = (ai-1 + ai+1)/2 - ci给你a0 、 an+1 和 c1~ cn 要求 a1易推2an=a(n-1) +a(n+1) -2cn;所以 2a1=a0+a2-2c1; 2a2=a1+a3-2c2; :
2013-08-16 16:01:09
840
转载 C语言中scanf()的用法!
好文章转自:http://blog.tianya.cn/blogger/post_show.asp?BlogID=287129&PostID=3668453scanf详解 scanf 原型: # include int scanf( const char *format, ... ); 函数 scanf() 是从标准输入流 stdin 中读内容的
2013-08-16 13:36:48
8355
原创 poj-2100 Graveyard Design
题目来源:http://poj.org/problem?id=2100睡前一水 直接暴力 一顿乱搞#include #include #include using namespace std;long long a[1000][2];int main(){ long long n; while(~scanf("%lld",&n)) {
2013-08-16 01:24:43
969
原创 poj-2479 简单DP
题目来源:http://poj.org/problem?id=2479题目大意就是求一个数组里面的两端连续值得最大和DP从前往后扫一遍 再从后往前扫一遍然后求1~i 和i+1~n的和的最大值注意题目要求必须得最低取两个数#include #include #define MAXN 50010#define MIN -10000using namespace std;i
2013-08-15 23:41:02
756
原创 poj-2484 A Funny Game
http://poj.org/problem?id=2484睡前也没想这么水的~ 但是运气就这样 哈哈博弈论真是说不清楚呀~#include #include using namespace std;int main(){ int n; while(~scanf("%d",&n)) { if(!n) bre
2013-08-15 01:36:21
733
原创 poj-2406 Power Strings睡前一水~
http://poj.org/problem?id=2406睡前一水~ 一看就觉得是KMP的next数组...然后果然是#include #include #include #define max 1000010int n[max];char str1[max];int next(char s[]){ n[0]=-1; int j=0,k=-1;
2013-08-15 00:36:49
1207
原创 poj-1740 A New Stone Game 博弈论
题目来源:http://poj.org/problem?id=1740刚刚看完博弈论的几篇文章,找了这水题,根据论文里面的思路很清楚了#include //只需要判断它是不是有N对相等的情况#include #include #include using namespace std;bool f[1005];int main(){ int n; whi
2013-08-14 21:11:03
845
转载 Game theory初步
http://www.cnblogs.com/Knuth/archive/2009/09/05/1561002.html游戏1l 有两个游戏者:A和B。l 有21颗石子。l 两人轮流取走石子,每次可取1、2或3颗。l A先取。l 取走最后一颗石子的人获胜,即没有石子可取的人算输。如果剩下1、2或3颗石子,那么接下来取的人就能获胜;如果剩
2013-08-14 19:56:27
929
转载 博弈论(二):Sprague-Grundy函数
转自:http://www.cnblogs.com/Knuth/archive/2009/09/05/1561007.html上一期的文章里我们仔细研究了Nim游戏,并且了解了找出必胜策略的方法。但如果把Nim的规则略加改变,你还能很快找出必胜策略吗?比如说:有n堆石子,每次可以从第1堆石子里取1颗、2颗或3颗,可以从第2堆石子里取奇数颗,可以从第3堆及以后石子里取任意颗……这时看上去问题复杂
2013-08-14 19:54:57
605
转载 博弈论(一):Nim游戏
http://www.cnblogs.com/Knuth/archive/2009/09/05/1561008.html重点结论:对于一个Nim游戏的局面(a1,a2,...,an),它是P-position当且仅当a1^a2^...^an=0,其中^表示位异或(xor)运算。Nim游戏是博弈论中最经典的模型(之一?),它又有着十分简单的规则和无比优美的结论,由这个游戏开始了解博弈
2013-08-14 19:53:12
847
转载 寻找必败态——一类博弈问题的快速解法
转自:http://www.cnblogs.com/Knuth/archive/2009/09/05/1561005.html 博弈是信息学和数学试题中常会出现的一种类型,算法灵活多变是其最大特点,而其中有一类试题更是完全无法用常见的博弈树来进行解答。 寻找必败态即为针对此类试题给出一种解题思路。 此类问题一般有如下特点:
2013-08-14 19:49:07
803
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人