摘要: 树状数组套主席树维护DFS序 网上linux交不过,windows下测可以,linux下Re 大家打check用吧#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <stack>#in... 阅读全文
posted @ 2013-04-23 14:54 SYFT 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 若第i个和第j个野人相聚,则有P[ i ] * b + C[ i ] = P[ j ] * b + C[ j ] ( mod m )m为洞的个数,移项得( P[ i ] – P[ j ] ) * b + ( C[ j ] – C[ i ] ) * 1 == Gcd( 1 ,b )所以可以枚举洞的个数,然后快速检验是否可行#include <cstdio>#include <cstring>#include <cstdlib>#include <ctime>#include <cmath>#include <iostream> 阅读全文
posted @ 2013-04-23 07:17 SYFT 阅读(456) 评论(0) 推荐(1) 编辑
摘要: 1.素数,整数分解,欧拉函数 素数是可能数论里最永恒,最经典的问题了。素数的判断,筛法求素数,大素数的判断···还有很多其他问题都会用到素数。 *最水最水的:(心情不爽时用来解闷吧) pku1365 Prime Land pku2034 Anti-prime Sequences pku2739 Sum of Consecutive Prime Numbers pku3518 Prime Gap p... 阅读全文
posted @ 2013-04-22 19:06 SYFT 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 数论问题总结一:欧几里德算法定理:gcd(a,b) = gcd(b,a mod b)证明:a可以表示成a = kb + r,则r = a mod b假设d是a,b的一个公约数,则有d|a, d|b,而r = a - kb,因此d|r因此d是(b,a mod b)的公约数假设d 是(b,a mod b)的公约数,则d | b , d |r ,但是a = kb +r因此d也是(a,b)的公约数因此(a,b)和(b,a mod b)的公约数是一样的,其最大公约数也必然相等,得证 。其算法:(a为任意非负整数,b为任意正整数)int gcd(inta,int b){if(a<b)return g 阅读全文
posted @ 2013-04-22 19:05 SYFT 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 题目大意:在矩形中找到一个点,使其跟最近的点距离最大算法:模拟退火模拟退火博大精深。。。#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#define max( x , y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )#define min( x , y ) ( ( x ) < 阅读全文
posted @ 2013-04-21 14:22 SYFT 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 本题我只过了80分,但是是正解,还有两个点无法过方法是1、先预处理处每两个字符串接在一起要增加多少个字符2、利用快速幂算出总共的长度下面给出代码 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 #include <ctime> 6 #include <iostream> 7 #include <algorithm> 8 #include <stack> 9 #include < 阅读全文
posted @ 2013-04-19 17:00 SYFT 阅读(146) 评论(0) 推荐(0) 编辑