会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
KasenBob
博客园
|
首页
|
新随笔
|
新文章
|
联系
|
订阅
|
管理
上一页
1
···
4
5
6
7
8
9
下一页
2018年11月30日
zoj-4011(动态规划)
摘要: 本题的动态规划公式是f[i][j]=f[i][j]+f[k][j-1],表示以i结尾的长度为j的序列,k为i的因子; 不难发现,计算中存在一个状态叠加的过程,即任意一个i都是它的因子的所有情况的叠加,例如[9][3],它会是以1,3结尾的长度为2的状态的叠加; 代码如下:
阅读全文
posted @ 2018-11-30 08:44 KasenBob
阅读(211)
评论(0)
推荐(0)
2018年11月28日
UVA-10791(唯一分解定理)
摘要: 注意特殊情况
阅读全文
posted @ 2018-11-28 21:17 KasenBob
阅读(189)
评论(0)
推荐(0)
2018年11月27日
UVA - 10375(唯一分解定理)
摘要: #include #include #include #include #include #include using namespace std; const int maxn=1e4+10; int prime[maxn],primey; int e[maxn]; void csh() { memset(prime,1,sizeof(prime)); prime[0]=pr...
阅读全文
posted @ 2018-11-27 22:40 KasenBob
阅读(178)
评论(0)
推荐(0)
UVA - 11582(模计算+快速幂)
摘要: #include #include #include #include #include typedef unsigned long long ll; using namespace std; const int maxn=1000+10; ll a,b; int f[maxn*maxn],n,M; int pow(ll a,ll p,int Mod) { int ret=1; ...
阅读全文
posted @ 2018-11-27 22:38 KasenBob
阅读(164)
评论(0)
推荐(0)
2018年11月26日
同余与模算术
摘要: 以下三条常用式子: (a+b)modn=((amodn)+(bmodn))modn (a-b)modn=((amodn)-(bmodn)+n)modn abmodn=(amodn)(bmodn)modn 大整数取模: 幂取模:
阅读全文
posted @ 2018-11-26 22:25 KasenBob
阅读(204)
评论(0)
推荐(0)
扩展欧几里得算法
摘要: 当需找出一对整数(x,y)使得ax+by=gdc(a,b)时,可使用扩展欧几里得算法; 注意,a需大于b,当a<0时需|a|x+by=gdc(|a|,b) 若方程ax+by=c的一组整数解为(x,y),则它的任意整数解都可以写成(x+kb,x+ka),其中a=a/gcd(a,b),b=b/gcd(a
阅读全文
posted @ 2018-11-26 19:53 KasenBob
阅读(133)
评论(0)
推荐(0)
杜教筛
摘要: 在查唯一分解定理的时候看到了杜教筛,查了一下挖槽这都什么鬼,立个flag要学; 积性函数和线性筛 https://www.cnblogs.com/zhoushuyu/p/8275530.html https://blog.csdn.net/skywalkert/article/details/505
阅读全文
posted @ 2018-11-26 11:34 KasenBob
阅读(95)
评论(0)
推荐(0)
2018年11月24日
算法训练(六)
摘要: 1.gym 101775A 本题是一个 C(n,k)+C(n,k+1)+...+C(n,n) 的过程,暴力会超时,转化为 2^n - C(n,0)+C(n,1)+...+C(n,k-1); 利用费马小定理(假如p是质数,且gcd(a,p)=1,那么 a(p-1)≡1(mod p),即:假如a是整数,
阅读全文
posted @ 2018-11-24 11:59 KasenBob
阅读(194)
评论(0)
推荐(0)
2018年11月23日
快速幂
摘要: int poww(int a,int b) { int ans=1,base=a; while(b!=0) { if(b&1!=0) ans*=base; base*=base; b>>=1; } return ans; }
阅读全文
posted @ 2018-11-23 20:03 KasenBob
阅读(80)
评论(0)
推荐(0)
2018年11月21日
八数码问题(刘汝佳版)
摘要: 可以采用dfs,对空白点进行操作,然后可用编码法,哈希表或者集合来标记,代码如下
阅读全文
posted @ 2018-11-21 21:38 KasenBob
阅读(388)
评论(0)
推荐(0)
上一页
1
···
4
5
6
7
8
9
下一页
公告