随笔分类 -  算法杂谈

摘要:/* HDU 3183 */ #include #include #include #include #include using namespace std; const int MAXN=1010; int a[MAXN]; int dp[MAXN][20]; void makeRMQIndex(int n,int b[])//形成最小值下标的RMQ { for(int i=0;... 阅读全文
posted @ 2016-03-12 19:53 柳下_MBX 阅读(220) 评论(0) 推荐(0)
摘要:#includelong long cnt;long long a[500001],t[500001];void merge(long long *a,long long *t,int l,int m,int r){ int p = l; int q = m+1; int k =... 阅读全文
posted @ 2015-12-03 19:43 柳下_MBX 阅读(156) 评论(0) 推荐(0)
摘要:ACM-高精度模板(综合篇) 时间:2015-02-01 20:30:23 阅读:419 评论:0 收藏:0 [点我收藏+] 标签:高精度 在这里,我们约定,能用int表示的数据视为单精度,否则为高精度。所有函数的设计均采用带返回值的形式。 本文包含 1.高精度加法 2.高精度减法 3.高精度乘法 1)高精度乘高精度的朴素算法 2)高精度乘... 阅读全文
posted @ 2015-10-12 22:43 柳下_MBX 阅读(452) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #include #include #include #include #pragma comment (linker,"/STACK:102400000,102400000") #define maxn 50005 #define MAXN 100... 阅读全文
posted @ 2015-10-08 20:26 柳下_MBX 阅读(267) 评论(0) 推荐(0)
摘要:位操作 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9064 Accepted: 3626 Description 假设你工作在一个32位的机器上,你需要将某一个外设寄存器的第X位设置成0(最低位为第0位,最高位为第31位), 阅读全文
posted @ 2015-08-28 16:57 柳下_MBX 阅读(390) 评论(0) 推荐(0)
摘要:有些程序要处理二进制位的有序集,每个位可能包含的是0(关)或1(开)的值。位是用来保存一组项或条件的yes/no信息(有时也称标志)的简洁方法。标准库提供了bitset类使得处理位集合更容易一些。要使用bitset类就必须要包含相关的头文件。在本书提供的例子中,假设都使用了std::bitset的u 阅读全文
posted @ 2015-08-28 16:32 柳下_MBX 阅读(341) 评论(0) 推荐(0)
摘要:Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 17487 Accepted: 6643 Description A square is a 4-sided polygon whose sides have equ 阅读全文
posted @ 2015-08-05 16:09 柳下_MBX 阅读(236) 评论(0) 推荐(0)
摘要:Time Limit: 7000MSMemory Limit: 65536KTotal Submissions: 48077Accepted: 17533DescriptionIn this problem, you have to analyze a particular sorting algo... 阅读全文
posted @ 2015-08-03 11:00 柳下_MBX 阅读(237) 评论(0) 推荐(0)
摘要:Who's in the MiddleTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 34974Accepted: 20396DescriptionFJ is surveying his herd to find the most a... 阅读全文
posted @ 2015-08-03 10:11 柳下_MBX 阅读(149) 评论(0) 推荐(0)
摘要:Encrypting passwords is one of the most important problems nowadays, and you trust only the encryp- tion algorithms which you invented, and you have j 阅读全文
posted @ 2015-07-31 18:50 柳下_MBX 阅读(207) 评论(0) 推荐(1)
摘要:A - Scary Martian Word Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1941 A - Scary Martian Word Su 阅读全文
posted @ 2015-07-29 19:21 柳下_MBX 阅读(222) 评论(0) 推荐(0)
摘要:位运算 位运算是把数字用二进制表示之后,对每一位上0或者1的运算。 理解位运算的第一步是理解二进制。二进制是指数字的每一位都是0或者1.比如十进制的2转化为二进制之后就是10。在程序员的圈子里有一个流传了很久的笑话,说世界上有10种人,一种人知道二进制,而另一种人不知道二进制。。。。。。 其实二进制 阅读全文
posted @ 2015-07-01 15:46 柳下_MBX 阅读(355) 评论(0) 推荐(1)
摘要:快速求正整数次幂 2007-05-05 12:21 快速求正整数次幂,当然不能直接死乘。举个例子: 3 ^ 999 = 3 * 3 * 3 * … * 3 直接乘要做998次乘法。但事实上可以这样做,先求出2^k次幂: 3 ^ 2 = 3 * 33 ^ 4 = (3 ^ 2) * (3 ^ 2)3 阅读全文
posted @ 2015-05-25 12:25 柳下_MBX 阅读(414) 评论(0) 推荐(0)