随笔分类 -  数学--数论

总结数论知识
摘要:题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4928 与HDU 5794相似 博客链接 题意:在一个棋盘状的网格中,有很多障碍点 阅读全文
posted @ 2016-10-21 20:48 茶飘香~ 阅读(432) 评论(0) 推荐(0)
摘要:51Node 1065 最小正子段和 N个整数组成的序列a[1],a[2],a[3],…,a[n],从中选出一个子序列(a[i],a[i+1],…a[j]),使这个子序列的和>0,并且这个和是所有和>0的子序列中最小的。 例如:4,-1,5,-2,-1,2,6,-2。-1,5,-2,-1,序列和为1 阅读全文
posted @ 2016-07-02 18:35 茶飘香~ 阅读(268) 评论(0) 推荐(0)
摘要:51Node 1035 最长的循环节 正整数k的倒数1/k,写为10进制的小数如果为无限循环小数,则存在一个循环节,求<=n的数中,倒数循环节长度最长的那个数。 1/6= 0.1(6) 循环节长度为1 1/7= 0.(142857) 循环节长度为6 1/9= 0.(1) 循环节长度为1 正整数k的倒 阅读全文
posted @ 2016-07-02 18:33 茶飘香~ 阅读(256) 评论(0) 推荐(0)
摘要:POJ 1681 Painter's Problem(高斯消元) Description There is a square wall which is made of n*n small square bricks. Some bricks are white while some bricks 阅读全文
posted @ 2016-06-16 18:25 茶飘香~ 阅读(200) 评论(0) 推荐(0)
摘要:转载自:高斯消元法 高斯消元法(Gauss Elimination) 分析 & 题解 & 模板——czyuan原创 高斯消元法,是线性代数中的一个算法,可用来求解线性方程组,并可以求出矩阵的秩,以及求出可逆方阵的逆矩阵。高斯消元法的原理是:若用初等行变换将增广矩阵 化为 ,则AX = B与CX = 阅读全文
posted @ 2016-06-15 11:00 茶飘香~ 阅读(498) 评论(0) 推荐(0)
摘要:ACdrea 1217 高斯消元 Description The following problem is somehow related to the final stage of many famous integer factorization algorithms involved in s 阅读全文
posted @ 2016-06-15 10:52 茶飘香~ 阅读(160) 评论(0) 推荐(0)
摘要:#include #include #include #include #include using namespace std; #define DIGIT 4 //四位隔开,即万进制 #define DEPTH 10000 //万进制 #define MAX 100+5 //题目最大位数/4,要不大直接设为最大位数也行 typedef... 阅读全文
posted @ 2016-06-13 11:39 茶飘香~ 阅读(190) 评论(0) 推荐(0)
摘要:DescriptionWhile resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter... 阅读全文
posted @ 2015-12-10 16:57 茶飘香~ 阅读(193) 评论(0) 推荐(0)
摘要:C. Duff and Weight Liftingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Duff has been... 阅读全文
posted @ 2015-10-24 20:47 茶飘香~ 阅读(181) 评论(0) 推荐(0)
摘要:frog hasnintegersa1,a2,…,an, and she wants to add them pairwise.Unfortunately, frog is somehow afraid of carries (进位). She defines \emph{hardness}h(x,... 阅读全文
posted @ 2015-10-02 11:48 茶飘香~ 阅读(225) 评论(0) 推荐(0)
摘要:逆元介绍 阅读全文
posted @ 2015-09-16 15:14 茶飘香~ 阅读(137) 评论(0) 推荐(0)
摘要:Every year there is the same problem at Halloween: Each neighbour is only willing to give a certaintotal number of sweets on that day, no matter how m... 阅读全文
posted @ 2015-08-04 16:32 茶飘香~ 阅读(180) 评论(0) 推荐(0)
摘要:输入n(using namespace std;typedef long long LL;LL a[15];LL gcd(LL a,LL b) //求a和b的最大公约数{ if(b) return gcd(b,a%b); return a;}LL lcm(LL a,LL b) //求a和b的最小公倍... 阅读全文
posted @ 2015-08-03 15:57 茶飘香~ 阅读(422) 评论(0) 推荐(0)
摘要:typedef long long LL;LL quick(LL a,LL b,LL m) //a^b%m 快速取模 使得复杂度从0(b){ // 降低为0(log2(b)) LL ans=1; while(b) { if(b&1) ans=ans*a%m; b>>=1; a=a*a%m; } re... 阅读全文
posted @ 2015-08-03 10:48 茶飘香~ 阅读(1026) 评论(0) 推荐(0)
摘要:输入N和M,M表示接下来会输入M个数,求从1到N中不能被这M个数整出的数的个数。思路:先算出从1到N中能被这M个数整除(即是这M个数中任意一个数的倍数)的数的个数,在用N减去就是答案了。#include #include using namespace std;long long num[20];l... 阅读全文
posted @ 2015-08-02 17:37 茶飘香~ 阅读(175) 评论(0) 推荐(0)
摘要:题意:将A(n , m)转化成k进制后末尾0的个数。分析:求A(n, m)转化成k进制以后末尾0的个数。对k素因子分解,第i个因子为fac[i],第i个因子的指数为num[i],然后再对n的对A(n, m)进行素因子分解,设count[i]代表fac[i]对应的指数,ans = min{count[... 阅读全文
posted @ 2015-08-01 19:51 茶飘香~ 阅读(1250) 评论(0) 推荐(0)
摘要:计算组合数C(m,n) 即从m个总体中取出n个的取法总数。一、直接用公式C(m,n)=m!/((m-n)!*n!) 或 C(m,n)=m*(m-1)*……*(m-n+1)/n!此方法只能计算较小的组合数代码实现:#include using namespace std;int main(){ in... 阅读全文
posted @ 2015-06-08 18:59 茶飘香~ 阅读(478) 评论(0) 推荐(0)