- 博客(40)
- 资源 (1)
- 收藏
- 关注
原创 mark一下
Archlinux中文化--怎么显示中文的界面http://www.360doc.com/content/12/0713/15/6828497_223986769.shtml
2015-07-16 20:01:54
420
转载 Said by Peter, Advises for ACM.
Do not spend all your time on training or studying - this way you will probably become very exhausted and unwilling to compete more. Whatever you do - have fun. Once you find programming is no fun a
2014-04-12 23:00:42
551
原创 关于 abs 的一点小问题
猜猜这个程序会输出什么?# include # include # include using namespace std;int main() { printf("%d ",abs(-2));}一开始很不理解,后来查了下abs函数的定义在 cmath 中只有: double abs (double x); floa
2014-02-15 15:30:40
725
原创 Wrong answer of URAL 1807
I don't know why TLE...# include # include # include # include # include # define EPS 1e-8using namespace std;vector prime;const int MAXN = 40000;bool p[MAXN+2];void init() { mem
2014-01-28 13:31:46
597
原创 special training
1. [easy] postering [link]2. [medium] Truchet Tiling [link]
2014-01-26 16:22:54
630
原创 wrong answer of URAL 1802
# include # include using namespace std;const int MAXN = 21;int A[6],B[6];const int C[][3] = {{0,2,4},{2,0,5},{2,4,0},{4,2,1},{4,0,2},{0,4,3}};#define rep(i,n) for(int i=0;i<n;i++)int n, c
2014-01-26 14:05:55
560
原创 代码库 显示多项式
显示多项式# include # include # include # include using namespace std;void output_poly(double a,int n,bool first) { if(fabs(a) < 1e-8) { if(first) cout << 0; return; } if (!first) {
2014-01-01 14:40:17
612
原创 树链剖分系列
树链剖分 代码集QTREE# include # include # include # include using namespace std;# define MAXN 10020struct node{ int m, L, R; node *l, *r; node(int a,int b): L(a),R(b),l(NULL),r
2013-06-16 18:22:37
626
原创 SGU 代码集 (Volume 1)
SGU 100~119 一句话题解,代码 (更新中……)100 A+B problem 101 Domio 构图,求一个欧拉路# include # include # include # include using namespace std;#define rep(i,n) for(int i=0;i<n;i++)#define PNA {puts("No soluti
2013-06-12 20:40:47
813
原创 Codeforces Round #157 小结
1. Little Elephant and Chess这道题一开始想复杂了,因为看漏了条件,每一行都是8个……直接输出就可以了……# include # define rep(i,n) for(int i=0;i<n;i++)char a[10]; bool flag=true;int main(){ rep(i,8){scanf("%s",a); rep(j,7)if(a[j]
2013-01-07 16:55:55
865
原创 codeforces Round#158 Div.2 小结
Codeforces Round # 158 (Div.2) 这次练习我有很大的收获。首先简单的题目不能想复杂了,像第一题,n=8,这个条件被我无视了;其次简单的贪心题目出了点问题,以后思维要更严密;然后c++的stl库用起来真的很方便。总之花了一天的时间把这套题AC了。A Adding Digits题目大意:定义操作(a,b)::在a后面添加一个数字(10进制),并使新的数字能
2013-01-05 20:01:56
976
原创 Code for fun (1)
矩阵乘法 (Size*Size)class mat{ const static int Size=10; unsigned long long a[Size][Size]; friend::mat operator*(const mat&a, const mat&b) { mat c; for(int i=0;i<Size;i++
2012-10-25 13:13:28
617
原创 [中山市选] 完全平方数
方法:欧拉筛法 莫比乌斯函数program number;const maxt=50000;var isprime:array[1..maxt]of boolean; prime:array[1..maxt]of longint; minu:array[1..maxt]of shortint; total,test,n:longint;
2012-07-20 09:47:50
1763
原创 [中山市选] 序列
直接上代码program seq;const maxn=100000+10;var a,f,g,f1,f2:array[0..maxn]of int64; i,j,n:longint; ans:int64;function max(i,j:int64):int64;begin if i>j then exit(i); exit(j);end;func
2012-07-20 09:45:59
1649
原创 [中山市选] 杀人游戏
原题:中山市选 2011 杀人游戏方法:Tarjan program kill_game;const maxn=100000; maxm=300000;type link=^node; node=record x:longint; next:link;end; procedure push(var x:link; const t:longint);var p:l
2012-07-20 09:21:11
2130
原创 阿狸的打字机
70分 裸的AC自动机program type2;type node=record son:array[0..25]of longint; fa,fail,key,e:longint; end;var a:array[1..100005]of node; sto:longint=1; st:array[1..100005]of char; len:longint; q,
2012-07-18 16:22:48
1065
原创 NOI 兔兔与蛋蛋的游戏
二维的一个最大匹配program game;type rec=record x,y:longint; end;const numm:rec=(x:0;y:0); dx:array[1..4]of integer=(0,1,0,-1); dy:array[1..4]of integer=(1,0,-1,0);var link:array[0..41,0..41]of re
2012-07-18 09:25:23
763
原创 NOI 项链工厂
原题:NOI 项链工厂方法:线断树program necklace;const maxn=500000;var ls,rs,s,cl,cr,z:array[1..maxn shl 2]of longint; sto,col,cur:longint; rev:boolean;procedure update(const x:longint);begin
2012-07-17 15:30:39
900
原创 《生成树计数》预处理
原题:NOI 生成树计数{ 预处理矩阵 }program predo;{start at 18:30}type state=array[1..6]of byte;var a:array[1..60]of state;c:state;n,i,j,tot:longint; mat:array[1..60,1..60]of longint;init:array[1..60]of lo
2012-07-16 20:22:42
436
原创 智能车比赛
(NOI2011 智能车比赛)program car;const inf=1e49;type node=record x,y:longint; end;operator -(a:node;b:node)c:node;begin c.x:=a.x-b.x; c.y:=a.y-b.y; end;operator *(a:node;b:node)c:double;begin c:
2012-07-15 19:23:04
797
原创 1D1D动态规划优化
原题:HNOI 玩具装箱方法:1D1D (模板)program toy;const maxn=55000;var s,f:array[0..maxn]of int64; q:array[0..maxn]of record l,r,c:longint; end; n,len:longint;procedure init;var i:lo
2012-07-15 11:00:30
2185
原创 搜索 MAYAN
原题:NOIP 2011 MAYAN类型:搜索 (小剪枝),不是很难program mayan;typebyte=integer; state=array[1..5,1..7]of byte; oper=object a,b,c:array[1..5]of byte; procedure push(d,x,y,t:byte); procedure print;
2012-07-11 14:08:52
428
原创 Link Cut Tree (paint)
原题:SDOI 2011 染色方法:LCT维护program paint;type link=^node; node=record x:longint; next:link; end;const maxn=100000;var q,f,l,r,c,lc,rc,rev,d:array[0..maxn]of longint; tp:array[0..max
2012-07-10 11:03:55
707
原创 Splay(sequence)
原题:NOI 2005 维护数列方法:单旋SPLAYprogram sequences;{$inline on}{start at 6:42}const maxn=500005;var l,r,w,s,sum,max,lm,rm,c,ss:array[0..maxn]of longint; rev:array[0..maxn]of boolean; top,k:long
2012-07-10 11:02:24
457
原创 SBT(pet)
原题:HNOI2004 宠物收养所方法:SBT 维护program size_balanced_tree;{$inline on}const maxn=80000;type point=^longint;var s,l,r,w:array[0..maxn] of longint; a,b:point; ans,m,t,k,now,root,sto:lo
2012-07-10 11:00:58
376
原创 Splay(dispatching)
原题:APIO 2012 派遣方法:splay 启发式合并program dispatching;const maxn=100000+100;type link=^node;node=record x:longint; next:link;end;var l,r,s,w,f,fa:array[1..maxn]of longint; ge:array[1..ma
2012-07-10 10:59:22
411
原创 块状树(count)
原题:ZJOI2008 count方法:块状树program count_trees;{$M 9999999}const maxn=30000+20;type link=^node; node=record x:longint; next:link; end;var own,w,dep,sum,size,fa,mun:array[0..maxn]of longint;
2012-07-10 10:57:21
1623
原创 炮兵阵地
炮兵阵地【DP+状态压缩】 program cannon;var n,m,tot,i,j,ans:longint;ch:char; sto:array[1..60]of longint; tor:array[1..60]of byte; a:array[0..100]of longint; f:array[0..100,0..60,0..60]of l
2011-11-10 19:22:01
580
原创 Dancing Links 模板
终于搞清楚了Dancing links是怎么写的了,并用P和C各写了一遍program poj_3740;var l,r,u,d,ch:array[0..10000]of longint; lin,col,size,o:array[0..1000]of longint; mx,bj,st,i,j,m,n,x,head:longint;procedure origin(
2011-10-30 19:49:54
769
原创 花园 打表0.1秒AC
今天做了一道题,打表,花了几个小时,当然最后0.1秒AC。【题目描述】【大意】有一个花园,可以看作3*3的格子花园中有四种花,分别是Lv1,Lv2,Lv3,Lv4,每种花都有其价值(不保证单调递增)Lv1的花可以任意种;Lv2的花必须在其相邻格子中种有Lv1的
2011-08-17 18:44:03
936
原创 HNOI 2010 弹飞绵羊
这道题听说要用splya做,但是我还不会写,所以我找了找题解,最后找到用分块原理做的。 代码很简洁,也很清楚。(参考资料:http://blog.youkuaiyun.com/jasonzhu8/article/details/5738434)var o,t,w,
2011-08-09 10:44:06
1247
原创 HNOI2004 打砖块
描述 Description 在一个凹槽中放置了n层砖块、最上面的一层有n 块砖,从上到下每层依次减少一块砖。每块砖都有一个分值,敲掉这块砖就能得到相应的分值,如下图所示。14 15 4 3 23 33 33 76
2011-08-08 21:47:40
992
原创 生日蛋糕问题 【最简洁代码】
生日蛋糕问题 剪枝program cake;var m,n,best,r,h:longint;procedure search(cs,nn,s,r,h:longint);var rn,hn:integer;begin if (cs=m+1) and
2011-07-29 14:10:05
5946
原创 一定不要想当然啊!!
我刚刚刷了能量项链说也不难,可是我却写了三次才AC。总结起来就是不要想当然。我用记忆化DP本应该一次AC的,但是第一次没有考虑 合并项链是将一列数合并成首尾两个数,而直接合并成一个数,所以错了在我发现这个错误之后,我又写了一遍,过了样例但是还是没有AC。因为我在dp的时候想当然的认为f[i,j]只和f[i,k]+f[k+1,j]有关,所以没过。今天下午我才发现的这个错误。哎
2011-06-23 18:22:00
447
原创 位运算 的适用范围
最近刷了几道水题,有一个就是纯数学题,最后算出公式为 (4^x-1)/3 +1,于是我便用 shl优化乘方运算:(1 shl (x+x) -1)div 3 +1; 结果总是后面几个点错了,我用的是qword,可还是错了。 然后我用exp(x*ln(4))算乘方就AC了。于是我逐步运行过程,发现shl 运算时大于31就出错了。 不知道是不是位运算的适用范围在2^32之内,反正总
2011-06-23 16:53:00
428
原创 Hnoi 第一题 homework 题解
【题目大意】求123456789101112131415……n构成的数mod m的值。【基本思路】我一开始用的是模拟,用一个字符串保存数字,再取模。这样显然超时,只能过一两个点。后来才知道是用动态规划写的,方程是P(i)=P(i-1)*10^k+ i .当然,直接动态规划的话效果也不好,所以我们用矩阵加速动归。【矩阵构造】我一开始是用别人的矩阵,也不知道原理。后
2011-06-21 13:21:00
415
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人