上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: 深夜无事可干啊 C++ include using namespace std; const int maxn = 1e6+11; typedef long long ll; bitset isnprime; int prime[maxn]; int sai(int n){ isnprime[0]= 阅读全文
posted @ 2018-01-13 03:09 Caturra 阅读(145) 评论(0) 推荐(0)
摘要: 这是对HDU1085的扩展,注意数组范围要4倍的n C++ include using namespace std; const int maxn = 2333; int G[2][maxn],n; int main(){ while(scanf("%d",&n)^ 1){ memset(G,0,s 阅读全文
posted @ 2018-01-12 19:12 Caturra 阅读(147) 评论(0) 推荐(0)
摘要: 年轻人的第一道母函数入门题 C++ include using namespace std; const int maxn = 1000+2000+5000+1; define rep(i,j,k) for(int i = j; i a b c){ if(!a&&!b&&!c) break; mem 阅读全文
posted @ 2018-01-12 11:39 Caturra 阅读(125) 评论(0) 推荐(0)
摘要: f[n]:sigma(i,n),i using namespace std; const int maxn = 1e6+11; const int Limit = 1e6; typedef unsigned long long ll; ll phi[maxn]; void euler(int n){ 阅读全文
posted @ 2018-01-12 10:35 Caturra 阅读(123) 评论(0) 推荐(0)
摘要: ```C++ include using namespace std; const int maxn = 1e6+11; const int N = 1e6; typedef long long ll; bitset isnprime; ll prime2[maxn 2]; int sai(){ i 阅读全文
posted @ 2018-01-12 09:24 Caturra 阅读(141) 评论(0) 推荐(0)
摘要: 依然是神奇的欧拉函数 若GCD(n,i)=k 则GCD(n/k,i/k)=1, 令i/k=x,有GCD(n/k,x)=1, →k GCD(n/k,x)=1中x的个数 = GCD(n,i)=k的和 范围就是求n的所有因子k C++ include using namespace std; const 阅读全文
posted @ 2018-01-11 23:12 Caturra 阅读(210) 评论(0) 推荐(0)
摘要: 求∑1/i,但是范围很大 和bitmap的想法一样,分个块,均摊复杂度就降下来了 //到底排行榜上的0ms是怎么做到的? C++ include using namespace std; const int maxn = 1e6+11; const int N = 1e8; double tmp[N 阅读全文
posted @ 2018-01-10 22:36 Caturra 阅读(117) 评论(0) 推荐(0)
摘要: 简单欧拉函数递推 用埃式筛会吃亏 C++ include include include include using namespace std; const int maxn = 5e6+11; typedef unsigned long long ll; ll phi[maxn]; void e 阅读全文
posted @ 2018-01-10 17:27 Caturra 阅读(121) 评论(0) 推荐(0)
摘要: 结论题:小于n的所有互质数之和为phi(n) n/2 阅读全文
posted @ 2018-01-10 16:33 Caturra 阅读(114) 评论(0) 推荐(0)
摘要: 结论:如果p是n的约数,那么满足gcd(i,n)==p的i的个数是Φ(n/p) 阅读全文
posted @ 2018-01-10 15:58 Caturra 阅读(134) 评论(0) 推荐(0)
摘要: 欧拉函数测试题 期末考试完了做下水题 更好的方法是phi[i]==i时就直接筛选,不改了 C++ include using namespace std; const int maxn = 4e4+11;; typedef unsigned long long ll; bool isnprime[m 阅读全文
posted @ 2018-01-10 00:32 Caturra 阅读(135) 评论(0) 推荐(0)
摘要: 部分还没调到满意的程度,效率比splay略好 C++ include using namespace std; const int maxn = 1e6+11; unsigned int SEED = 17; inline int Rand(){ SEED=SEED 1103515245+12345 阅读全文
posted @ 2017-12-19 23:44 Caturra 阅读(184) 评论(0) 推荐(0)
摘要: ```C++ include using namespace std; const int maxn = 2e6+1e5; unsigned int SEED = 17; inline int Rand(){ SEED=SEED 1103515245+12345; return SEED; } ty 阅读全文
posted @ 2017-12-19 01:29 Caturra 阅读(166) 评论(0) 推荐(0)
摘要: 实测手动实现1e7范围比内置快3倍左右 PS xjb乱敲也是可以的 C++ include unsigned int xjb=2333333; int Rand(){ return (xjb=xjb 12345+23333)%7; } int arr[33],cnt,i; int main(){ w 阅读全文
posted @ 2017-12-18 19:04 Caturra 阅读(206) 评论(0) 推荐(0)
摘要: ```C++ include include include include define rep(i,j,k) for(int i = j; i n m){ rep(i,1,n)rep(j,1,m)cin a[i][j]; memset(dp,0,sizeof dp); rep(i,1,n)dp[ 阅读全文
posted @ 2017-12-12 16:20 Caturra 阅读(125) 评论(0) 推荐(0)
摘要: 迭代式不知道怎么敲 DFS就很清晰 C++ include include include include include include define rep(i,j,k) for(int i = j; i =1&&i=1&&jG[i][j]) maxlen=max(maxlen,DP(x,y)+ 阅读全文
posted @ 2017-12-12 14:52 Caturra 阅读(116) 评论(0) 推荐(0)
摘要: 要求max{F/P},先枚举下界lowf,再贪心求符合约束条件的n个最小价值和 记录F的离散值和去重可以大幅度常数优化 (本来想着用DP做的) (辣鸡POJ连auto都Complie Error) DP写法 因为二维的dp[][k]是滚动更新的,所以每次更新当前最小值是dp[i 1][k]必然存在最 阅读全文
posted @ 2017-12-12 00:32 Caturra 阅读(132) 评论(0) 推荐(0)
摘要: f[i][j]:i种花放j盆的方案数 C++ include using namespace std; const int maxn = 3e2+11; const int mod = 1000007; typedef long long ll; ll f[maxn][maxn],a[maxn],n 阅读全文
posted @ 2017-12-11 18:39 Caturra 阅读(160) 评论(0) 推荐(0)
摘要: 从来不会DP的家伙终于要开始重拾DP了 最大子矩阵没啥好说的,注意单调最大子矩阵不用这么高复杂度,另行更新 阅读全文
posted @ 2017-12-11 01:26 Caturra 阅读(119) 评论(0) 推荐(0)
摘要: http://blog.csdn.net/jinzhao1993/article/details/51383503 阅读全文
posted @ 2017-12-11 00:55 Caturra 阅读(103) 评论(0) 推荐(0)
摘要: 搜索苦手,注意正负 C++ include define rep(i,j,k) for(int i = j; i n) cout 阅读全文
posted @ 2017-12-10 13:18 Caturra 阅读(122) 评论(0) 推荐(0)
摘要: 首先要判sum是否是3的整数倍 然后把符合条件的前缀和以及后缀和分别加入到静态vector中 最后扫一下j和k定位在哪然后求总长的差来更新答案 注意i j k至少隔1位,所以lower_bound是s1[i]+2 官方题解是O(n),不过没仔细看 这种解法最坏应该是常数较小的O(nlogn) C++ 阅读全文
posted @ 2017-12-09 18:49 Caturra 阅读(225) 评论(0) 推荐(0)
摘要: 求最小不重复匹配次数 改最后一个字符最划算 我当时怎么就没看出来.. C++ include using namespace std; string S,T; int main(){ while(cin S T){ int ans=0; for(int i = 0; i 阅读全文
posted @ 2017-12-09 15:12 Caturra 阅读(179) 评论(0) 推荐(0)
摘要: 显然只需要能跑到第二个因子就赢了 需要特判非平凡因子 常数优化:不用求出所有因子,跑完第二个素数就行了 C++ include using namespace std; typedef long long ll; const int maxn = 233; ll n,cnt; ll prime[ma 阅读全文
posted @ 2017-12-09 11:28 Caturra 阅读(200) 评论(0) 推荐(0)
摘要: 要求断裂的数列之和的最大值,只需在断裂处的下标修改为一个足够负无穷大的值就可以用线段树维护 这道题数据还是弱了点,如果n和ai均取最大可能我这个程序早就爆ll了(4e4的时候炸了),毕竟本来想着用GCC的int128稳过却CE(我dev用着好好的) 本着死马当活马医的可贵精神直接改回ll碰碰运气,没 阅读全文
posted @ 2017-12-09 10:39 Caturra 阅读(244) 评论(0) 推荐(0)
摘要: https://www.cnblogs.com/xiaochaoqun/p/4898990.html http://blog.csdn.net/qq_36398723/article/details/78401832 阅读全文
posted @ 2017-12-08 20:58 Caturra 阅读(139) 评论(0) 推荐(0)
摘要: ```C++ include using namespace std; const int maxn = 2e5+2e4+11; const int dep = 666; const int len = 30; struct AAA{ string str; int cnt; }a[maxn]; b 阅读全文
posted @ 2017-12-08 00:28 Caturra 阅读(122) 评论(0) 推荐(0)
摘要: //f(u) =f(v)+w //求最大值 跑最短路 v u w //求最小值 跑最长路 u v w 阅读全文
posted @ 2017-12-06 00:49 Caturra 阅读(166) 评论(0) 推荐(0)
摘要: LCA模板题 随便找的倍增模板... C++ include using namespace std; const int maxn = 1e5+11; int to[maxn que; memset(dis,0,sizeof dis); memset(fa,0,sizeof fa); memset 阅读全文
posted @ 2017-12-05 16:42 Caturra 阅读(138) 评论(0) 推荐(0)
摘要: 数目规模大,尝试转换为判定性问题,那么E就不影响到网络流的复杂度了 SPFA码歪了,WA了好几发气死了 C++ include using namespace std; const int maxn = 3e5+11; const int oo = 0x3f3f3f3f; int to[maxnf) 阅读全文
posted @ 2017-11-29 21:45 Caturra 阅读(201) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 下一页