自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 poj1068Parencodings

http://poj.org/problem?id=1068 1.利用P-sequence里的数值,还原出括号串S。 2.从左往右遍历括号串S,遇到右括号停止,设置计数器。指针回退,遇到左括号不管有没有匹配过,都要 计数器+1,直到遇到左括号没有匹配过停止。新匹配的左括号处置新的特殊字符,标记为访问过,为下一次 指针回退做准备。 #include char S[25]; int

2016-05-30 18:00:22 322

原创 poj1002 487-3279

http://poj.org/problem?id=1002 贴一发老外写的代码:。我一开始写了一百多行,然后WA了。 借鉴一下map映射技巧,qsort排序技巧。 #include #include #include char map[26] = {'2', '2', '2', '3', '3', '3', '4', '4', '4','5', '5', '5', '6', '6

2016-05-29 23:04:08 266

原创 ACM ICPC2011–2012 Northeastern European Regional Contes Problem E. Eve

http://neerc.ifmo.ru/past/2011/neerc-2011.pdf 并查集解决DNA遗传问题,对新手来说难度较大。 贴一发大神的代码,西南民大称他安神,大一获得四川ACM省赛金奖。 #include #include #include int n,m,K; int DNA[300000]; int a[300000]; int b[300000]; int

2016-05-29 22:55:05 439

原创 poj2524Ubiquitous Religions

http://poj.org/problem?id=2524 并查集的基本操作,路径压缩等 #include int parent[50005],count; /*思想:每次查找的时候,如果路径较长,则修改信息,以便下次查找的时候速度更快*/ int find (int x)//带路径压缩的查找算法 { int r; for (r = x; parent[r] != r; r =

2016-05-29 22:44:11 251

原创 山东理工OJ 区间覆盖问题

/*区间覆盖问题: Time Limit: 1000MS Memory limit: 65536K (1).题目描述: 用i来表示x坐标轴上坐标为[i-1,i]的长度为1的区间,并给出n(1≤M≤200)个不同的整数,表示n个这样的区间。 现在要求画m条线段覆盖住所有的区间, 条件是:每条线段可以任意长,但是要求所画线段的长度之和最小, 并且线段的数目不超过N(1≤N≤50)。 (2).

2016-05-29 22:38:16 699

原创 poj1328Radar Installation

http://poj.org/problem?id=1328 按右端点升序排序。 贪心,每次贪心选取“右端点”,实在取不到交集,雷达个数才加一。 然后再贪心的选取“右端点”,重复上述过程。 #include #include #include //gcc -o xxx xxx.c -lm typedef struct node { double x,y; }Node; in

2016-05-29 22:27:21 275

原创 poj1001Exponentiation

http://poj.org/problem?id=1001 高精度计算,大数处理 #include #include int main() { int a[150],b[150],c[150]; char base[10]; /*底数字符串*/ int exp; /*指数*/ int temp,flag,i,j,k,digit; int baselast,alast,b

2016-05-29 22:18:13 259

原创 HihoCoder 93week Eular质数筛法

http://hihocoder.com/contest/hiho93/problem/1 我们可以知道,任意一个正整数k,若k≥2,则k可以表示成若干个质数相乘的形式。Eratosthenes筛法中,在枚举k的每一个质因子时,我们都计算了一次k,从而造成了冗余。因此在改进算法中,只利用k的最小质因子去计算一次k。 首先让我们了解一下Eular筛法,其伪代码为: isPrime[]

2016-05-29 22:07:23 275

原创 hihoCoder 92week Miller-Rabin质数测试

http://hihocoder.com/contest/hiho92/problem/1 这种质数算法是基于费马小定理的一个扩展。 首先我们要知道什么是费马小定理: 费马小定理:对于质数p和任意整数a,有a^p ≡ a(mod p)(同余)。反之,若满足a^p ≡ a(mod p),p也有很大概率为质数。 将两边同时约去一个a,则有a^(p-1) ≡ 1(mod p) 也即是说:假

2016-05-29 21:54:37 356

原创 POJ1543 Perfect Cubes

http://poj.org/problem?id=1543 分析题意,挖取关键信息:     (1). b^3 + c^3 + d^3 = a^3     (2). integers greater than 1,即a,b,c,d均大于1     (3). b,c,d非降序     所以对于某个确定的N,有:1         对于某个确定的a,有:1         对于某个

2016-05-29 21:17:27 298

原创 pojFinancial Management1004

http://poj.org/problem?id=1004 #include int main() { float month[12], sum = 0.0, average; int i= 0; for(i = 0; i< 12;i++) { scanf("%f",&month[i]); sum += month[i]; }

2016-05-29 21:10:42 244

原创 poj2109Power of Cryptography

http://poj.org/problem?id=2109 pow函数用法~ #include #include int main() { int n; double p; while(scanf("%d %lf",&n,&p)!=EOF) printf("%.0f\n",pow(p,1.0/n)); return 0; }

2016-05-29 20:51:39 206

原创 poj1003Hangover

http://poj.org/problem?id=1003 装个逼,用动态内存分配。 #include #include int main() { float* num; float n,sum; int i = 0,j,temp; scanf("%f",&n); while(n != 0.00) /*输入测试样例*/ { if(

2016-05-29 20:44:14 292

原创 hdu2037今年暑假不AC

http://acm.hdu.edu.cn/showproblem.php?pid=2037 算法导论里的活动安排问题,典型的贪心算法 C版本,注意qsort函数(头文件:stdlib.h)里的compare该怎么写。 #include #include typedef struct program { int start,end; }program; int compare(co

2016-05-29 20:27:04 320

原创 hdu2005第几天?

http://acm.hdu.edu.cn/showproblem.php?pid=2005 注意数组的预处理,不要用switch case #include int leapmonth[12] = {0,31,29,31,30,31,30,31,31,30,31,30}; //闰年0~11月 int commonth[12] = {0,31,28,31,30,31,30,31,31,3

2016-05-29 20:20:50 332

原创 poj1182食物链

http://poj.org/bbs?problem_id=1182 并查集,带权并查集~ 方法一: //Memory: 744K Time: 235MS #include int p[150000]; int find(int x)//find函数功能为找到与x相关联的第一个输入项,比如可能有很多个输入是同类或有间接捕食关系,可以找到所有关联项的第一个,把所有输入都逻辑串联 {

2016-05-29 20:06:31 270

原创 poj1686Lazy Math Instructor

http://poj.org/problem?id=1686 构造栈,表达式求值。我只会C语言。。 #include #include char opp[8] = {'+','-','*','/','(',')','#'}; int priority[7][7] = {{1,1,-1,-1,-1,1,1},{1,1,-1,-1,-1,1,1},{1,1,1,1,-1,1,1},{1,1,

2016-05-29 19:55:32 380

原创 poj1747Expression

http://poj.org/problem?id=1747 给出一个函数 要求找出各位的表示方法 判断是否能进位。 记*为n=k-1时的表达式, 则n=k时,表达式为 ((An-1|Bn-1)|(*|((An-1|An-1)|(Bn-1|Bn-1))))。 递归函数的结构为:先输出*左边的部分,然后输出*,再输出*右边的部分。 边界条件为n=1,此时表达式为((A0|B0)|(A

2016-05-29 19:46:07 305

原创 poj1598Excuses, Excuses!

http://poj.org/problem?id=1598 找出含所给关键字最多的那个句子 #include #include char keyword[25][25],excuses[25][75]; char temp[75]; void StringChangeLower(char* s) //大写字母转小写字母 { int i; for(i = 0; i < strlen(s

2016-05-29 19:31:13 346

原创 poj1488TEX Quotes

http://poj.org/problem?id=1488 没技术含量,不过可以学学flag的技巧 #include int main() { char ch; int flag = 1; while((ch = getchar()) != EOF) { if(flag == 1&&ch == '"') { printf("``"); flag = 0;

2016-05-29 19:20:34 305

原创 poj1222EXTENDED LIGHTS OUT

http://poj.org/problem?id=1222 既然按钮按下的顺序不影响最后的结果,不妨假设从第一行往下一行一行按按钮 按第二行按钮时必须把第一行灯全部熄灭, 否则第三行以后的按钮再也不能改变第一行的灯。 按第三行必须把第二行熄灭, 按第四行必须把第三行熄灭, 按第五行必须把第四行熄灭, 由于没有行能把第五行熄灭,所以此时看第五行的灯是否全部熄灭,若全部熄灭则找到了答案

2016-05-29 18:56:51 411

原创 poj2506Tiling

http://poj.org/problem?id=2506 递推:f(n)=f(n-1)+2f(n-2) #include struct node { int a[10000]; }s[300]; int main() { int c,n,i,j,cot=1; long long temp; s[0].a[0]=1; s[1].a[0]=1; for(i=2;i<260;i

2016-05-29 17:33:50 411

原创 poj3295Tautology

http://poj.org/problem?id=3295 表达式运算符合栈的结构特点,构造一个栈进行运算。 p,q,r,s,t的值共有2的五次方种可能组合,当成二进制不断加一进行枚举。 #include #include char wff[200]; int operand[200],value[6]; int Caculate(char ch,int u,int v) {

2016-05-29 17:15:50 259

原创 poj1753 Flip Game

http://poj.org/problem?id=1753 位压缩,广度优先搜索 异或运算的用途之一:使某些特定的位翻转,例如对数10100001的第2位和第3位翻转,则可以将该数与00000110进行按位异或运算。 10100001^00000110 = 10100111 将当前棋局状态拟化为一个二进制数,比如: w w w w w w w w w w w w w w w w

2016-05-27 15:38:51 241

原创 poj2965The Pilots Brothers' refrigerator

http://poj.org/problem?id=2965 按下‘+’按钮,再把‘+’号所在行和列的按钮全部按一遍,这样就把‘+’变成‘-’而不改变其他任何按钮。 mark[][]初始化全置0,按过的地方改为1,再按一次又变为0,抵消上一次操作。mark[][]为1的位置,按过了奇数次,为0的位置按过了偶数次(跟没按一样,所以不需要动它)。 最终mark[][]为1的位置即为所求。

2016-05-27 15:11:39 226

空空如也

空空如也

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

TA关注的人

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