
数论
zz_ylolita
这个作者很懒,什么都没留下…
展开
-
【bzoj2242】计算器——数论综合
终于在bzoj上AC一题了,虽然是看题解写的。。。原创 2014-08-16 18:09:49 · 1062 阅读 · 0 评论 -
CF1114F. Please, another Queries on Array?
没有注意到所有的因子都是300以内,注意到了也想不到这样就可以用集合来表示质数是否出现,从而直接计算出欧拉函数。 打标记的线段树在change的时候忘记pushdown了,调了一天orz #include <iostream> #include <cstdio> #include <string> #include &am原创 2019-02-12 23:43:57 · 362 阅读 · 0 评论 -
bzoj4659LCM
总感觉我的做法是假的莫比乌斯反演。。 只用到了莫比乌斯函数的性质 复杂度是O(nlogn)的,这题正好p是2^30可以用int自然溢出,不用取模,但是最后的答案还是要+p在%p,防止是负数 #include <bits/stdc++.h> using namespace std; const int P = 1<<30; #define N 4000005 int ...原创 2018-09-23 20:49:49 · 181 阅读 · 0 评论 -
luogu1829 [国家集训队]Crash的数字表格 / JZPTAB
式子好难推。。看别人的博客好了。。 #include <bits/stdc++.h> using namespace std; #define N 10000005 #define P 20101009 bool vis[N]; int prime[N],miu[N]; typedef long long LL; LL x[N], ans; int cnt,n,m; void ...原创 2018-09-23 18:10:33 · 243 阅读 · 0 评论 -
luogu2522[HAOI2011]Problem b
用一个简单的容斥就可以求出a<=x <=b, c<=y<=d范围的答案了 注意1LL呀qwq #include <bits/stdc++.h> using namespace std; #define N 50005 bool vis[N]; int miu[N],prime[N]; typedef long long LL; LL sum[N],ans;...原创 2018-09-23 16:42:40 · 141 阅读 · 0 评论 -
luogu3455 [POI2007]ZAP-Queries——莫比乌斯反演
比上一题更简单。。。 #include <bits/stdc++.h> using namespace std; #define N 50005 bool vis[N]; int miu[N],prime[N]; typedef long long LL; LL sum[N],ans; int n,m,d,T,cnt; void Miu() { miu[1] = 1; cnt ...原创 2018-09-23 16:27:29 · 215 阅读 · 0 评论 -
luogu2257 YY的GCD——莫比乌斯反演
注意一下处理前缀和的时候的trick #include <bits/stdc++.h> using namespace std; #define N 10000005 bool vis[N]; int miu[N]; typedef long long LL; LL sum[N],ans,g[N]; int prime[N]; int cnt,T,n,m; void Miu() {...原创 2018-09-23 16:03:00 · 199 阅读 · 0 评论 -
欧拉函数
codevs4415 #include #include #include #include using namespace std; #define LL long long LL a,b,c,n; LL phi(LL x)//求单个欧拉函数的算法 { LL t=x; for (LL i=2;i*i<=x;i++) //注意i*i<=x的表示 if (x % i==0)原创 2015-11-02 20:56:48 · 418 阅读 · 0 评论 -
贾志鹏线性筛
贾志鹏线性筛题目原创 2015-11-02 21:00:52 · 1222 阅读 · 0 评论 -
noip2014Day2T3解方程
理论上70分 将a[i]模一个大质数,然后O(nm) p=10^7+7比较科学 program ttt; const p=10000007; var n,v,j,m,t,i,ss:longint; a:array[0..100]of longint; c:array[1..100000]of longint; procedure readdata(i:longint); var s原创 2015-05-28 20:33:06 · 2464 阅读 · 0 评论 -
poj1061
program p1061; var x,y,n,m,l,a,b,d,xx,yy:int64; function exgcd(a,b:int64;var x,y:int64):int64; var t:int64; begin if b=0 then begin x:=1;y:=0; exgcd:=a; end else begin exgcd:=exgcd(b,原创 2014-12-27 12:30:21 · 478 阅读 · 0 评论 -
中国剩余定理
program t; var n,i:longint; j,k,m,x,y,ans,m1:int64; a,b:array[1..10]of int64; procedure gcd(a,b:int64;var x,y:int64); var t:int64; begin if b=0 then begin x:=1;y:=0;exit; end; gcd(b,a原创 2014-12-07 18:06:47 · 706 阅读 · 0 评论 -
vijosP1279 Leave-绿光
题目描述: 将边长为正整数a,b的长方形划分成若干边长均为正整数,每个正方形的边均平行于矩形的相应边,试求这些正方形边之和的最小值MIN。 (如果这个长方形可以分成N个正方形,其中每个边长为Ai,那么MIN=A1+A2+^^^+AN 注意,数组A中的元素可能相等) 分析:要求正方形边长之和的最小值,切割下来的正方形应当尽可能大。又由于只要累加一个边长,最后一个切下来的正方形边长原创 2014-12-06 17:47:57 · 857 阅读 · 0 评论 -
扩展欧几里德
program exgcd; var a,b,x,y:int64; function safe(x:int64):int64; begin safe:=((x+b) mod b+b) mod b; end; procedure ext_gcd(a,b:int64;var x,y:int64); begin if b=0 then begin x:=1;y:=0;原创 2014-10-16 18:58:02 · 461 阅读 · 0 评论 -
Lucas 定理
转载请注明出处,谢谢 http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents by---cxlove Lucas 定理:A、B是非负整数,p是质数。AB写成p进制:A=a[n]a[n-1]...a[0],B=b[n]b[n-1]...b[0]。 则组合数C(A,B)与C(a[n],b[n])*C(a[n-1],b[转载 2014-10-03 21:24:03 · 399 阅读 · 0 评论 -
【bzoj2257】墨墨的等式
//在n个数中找k个使得它们的最大公约数最大:枚举所有原创 2014-08-16 19:04:08 · 1170 阅读 · 0 评论 -
BZOJ2118 墨墨的等式[一个图论模型]
由于某些原因,题解之后再写 好久没有这么开心的写代码了,但是还有2个小细节没注意到qwq,下次注意。 //BZOJ2118 //图论模型 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <queue> using na...原创 2019-07-08 15:39:27 · 335 阅读 · 0 评论