![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论与组合数学系列
文章平均质量分 68
phython96
ACM退役~
展开
-
ACM一类方程问题的求解[最短路建模] bzoj2118
在ACM生涯里已经预见两回判断这种方程是否有解、有几个解的问题了。例如:1给定非负整数a,b,c,n,请判断ax+by+cz=n是否存在(x,y,z)均为非负整数的解题目链接:http://oj.xjtuacm.com/contest/14/problem/124/再例如:2现有方程A1 * X1 + A2 * X2 + ... + An * Xn =原创 2017-07-11 19:43:54 · 431 阅读 · 0 评论 -
codeforces -891B Gluttony 排列,构造题
B. Gluttony time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an array a with n distinct integers. Construct an array b by per原创 2017-11-18 16:36:20 · 907 阅读 · 0 评论 -
"简单"的数学问题 洛谷 P1414 又是毕业季II
题意给出n个数字,询问从中挑出k个数字,最大可能的公共gcd是多少。题解k个数的gcd一定出现至少k次。 我们遍历所有的数并对每个数字求它所有的因子,统计各个因子出现的个数。 给定k时,我们的答案就是所有出现次数>=k的因子的最大值。代码#include <iostream>#include <cstdio>using namespace ...原创 2018-03-18 13:11:21 · 169 阅读 · 0 评论 -
组合数学与数论函数专题
组合数学专题专题简介本专题包含了一些组合数学中常见的套路和方法,如拉格朗日插值,动态规划,容斥原理,狄利克雷卷积,线性筛,杜教筛 等等.目录2018 四川省赛GRISAIA (数论分块)HDU 6428 Calculate (狄利克雷卷积,线性筛)BZOJ4559 成绩比较 (动态规划,拉格朗日插值)BZOJ 2633 已经没有什么好害怕的了 (容斥森林,动态规划)...原创 2018-09-15 23:20:23 · 352 阅读 · 0 评论 -
牛客练习赛29 题解
根据裴蜀定理,当存在一些x的组合,使得它们的gcd为1的时候,p1x1+p2x2+...+pnxn=1p_1x_1 + p_2x_2 + ... + p_nx_n = 1p1x1+p2x2+...+pnxn=1,方程一定有解.因此我们就求gcd(x1,x2,...,xn)=1gcd(x_1,x_2,...,x_n) = 1gcd(x1,x2,...,xn)=1的方案数即可记f...原创 2018-10-19 22:45:57 · 442 阅读 · 3 评论 -
Wannafly 挑战赛27 题解
Wannafly 挑战赛27题目连接https://www.nowcoder.com/acm/contest/215#questionA.灰魔法师题目题解考虑到可能的完全平方数只有400400400多个,因此对于每种数,直接暴力枚举所有的完全平方数计算一下就可以了.代码#include &lt;iostream&gt;#define int long longconst i...原创 2018-10-29 10:00:49 · 215 阅读 · 0 评论 -
UVA10601 Cubes - 波利亚定理
Cubes题意给出121212根长度相等的木棒,颜色最多有666种,问能构成的本质不同的正方体数量.题解根据波利亚定理公式:设X是元素集合,G是X的置换群,{u1,u2,...,uk}\{u_1,u_2,...,u_k\}{u1,u2,...,uk}是kkk种颜色的集合,CCC是XXX的任意着色集.这时,针对各颜色的数目的C的非等价着色数的生成函数是:PG(u1+...+uk,...原创 2018-11-04 09:18:56 · 380 阅读 · 0 评论 -
P3768 简单的数学题 [狄利克雷卷积,杜教筛,莫比乌斯反演]
简单的数学题题目连接https://www.luogu.org/problemnew/show/P3768题目描述输入一个正整数n,n≤1010n,n\le 10^{10}n,n≤1010和p,p≤1.1×109p,p \le 1.1 \times 10^9p,p≤1.1×109.且ppp为质数.计算∑i=1n∑j=1nijgcd(i,j)\sum_{i=1}^n\sum_{j=1}^n...原创 2018-11-05 12:25:22 · 215 阅读 · 0 评论 -
P2522 HAOI2011 Problem b [莫比乌斯反演,数论分块]
P2522 HAOI2011题意对于给出的n个询问,每次求有多少个数对(x,y)(x,y)(x,y),满足a≤x≤ba≤x≤ba≤x≤b,c≤y≤dc≤y≤dc≤y≤d,且gcd(x,y)=kgcd(x,y) = kgcd(x,y)=k,gcd(x,y)gcd(x,y)gcd(x,y)函数为xxx和yyy的最大公约数.题解即求式子∑x=ab∑y=cd[gcd(x,y)=k]\sum_{x=...原创 2018-11-05 22:03:53 · 216 阅读 · 0 评论 -
codeforces839D Winter is here 数论,莫比乌斯反演
D. Winter is heretime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWinter is here at the North and the White原创 2017-08-13 09:27:35 · 1047 阅读 · 3 评论 -
codeforces 850B Arpa and a list of numbers
B. Arpa and a list of numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArpa has found a list contain原创 2017-09-05 20:19:06 · 513 阅读 · 0 评论 -
Summer Training day4 Mod Tree 大步小步法求离散对数模板
The picture indicates a tree, every node has 2 children. The depth of the nodes whose color is blue is 3; the depth of the node whose color is pink is 0. Now out problem is so easy, give you a原创 2017-08-07 19:27:15 · 332 阅读 · 0 评论 -
2017西安交大ACM小学期数论 [等差数列]
等差数列发布时间: 2017年6月25日 13:42 最后更新: 2017年7月3日 09:27 时间限制: 1000ms 内存限制: 128M描述给定正整数n,试问存在多少个和为n的等差数列?当然,等差数列中每一项要为非负整数,且不考虑降序的等差数列。输入多组输入数据(不超过1000组)。每组数据一个正整数n,1≤n≤109。原创 2017-07-05 11:01:39 · 395 阅读 · 0 评论 -
2017西安交大ACM小学期数论 [完全平方数]
完全平方数发布时间: 2017年6月24日 17:01 最后更新: 2017年7月3日 09:27 时间限制: 1000ms 内存限制: 128M描述给定正整数b,求最大的整数a,使a(a+b)是完全平方数。输入多组测试数据(不超过10000组)。每组数据一个正整数b,b≤109。输出对每组数据输出一行一个整数a,表示答案原创 2017-07-05 10:44:27 · 742 阅读 · 2 评论 -
2017西安交大ACM小学期数论 [更新学号]
发布时间: 2017年6月24日 20:27 最后更新: 2017年7月3日 09:27 时间限制: 3000ms 内存限制: 128M描述某知名高校有n个学生,每个学生有一个唯一ID。但这些ID有7位数字,学生总是记不住,于是学校想了一个办法。它们将所有ID对m取模作为学生的新ID。显然,取模后要保证这些ID仍不相同。校长听说参加西安交通大学ACM培训的学生能帮忙解决原创 2017-07-05 10:55:01 · 1000 阅读 · 0 评论 -
2017西安交大ACM小学期数论 [水题]
水题发布时间: 2017年6月25日 14:06 最后更新: 2017年7月3日 09:27 时间限制: 1000ms 内存限制: 128M描述平均因数个数的统计对于估算数论题目复杂度具有非常重要的意义。小A同学听了今天的课后,于是想要自己写一个程序,求出1到n的平均因数个数。小A当然会啦!但是他想考考你。输入多组输入数据(不超过1000组)原创 2017-07-05 10:30:54 · 436 阅读 · 0 评论 -
2017西安交大ACM小学期数论 [阅兵式]
阅兵式发布时间: 2017年6月25日 12:53 最后更新: 2017年7月3日 09:27 时间限制: 1000ms 内存限制: 128M描述阅兵式上,将士们排成一个整齐的方阵,每个将士面朝前方。问正中心的将士能向前看到几个将士?注意,一条直线上的将士会产生遮挡关系。输入多组输入数据(不超过10000组)。每组数据一行一个原创 2017-07-05 10:23:08 · 308 阅读 · 0 评论 -
Summer Training day4 欧拉降幂
Input2Output2 Hint 1. For N = 2, S(1) = S(2) = 1.2. The input file consists of multiple test cases. Sample Input2Sample Output2原创 2017-08-07 19:04:36 · 552 阅读 · 0 评论 -
Summer Training day4上帝与集合的正确用法 欧拉函数+降幂公式
这个题的指数太大了,因此要考虑用降幂公式进行降幂记f(p) = 2^2^2... % pf(p) = 2^(2^2^2...%phi(p) + phi(p)) % p = 2^(f(phi(p)) + phi(p)) % p到这里我们得到了一个递推方程,边界f(1) = 0#include #include #include using namespace std;type原创 2017-08-07 19:11:47 · 230 阅读 · 0 评论 -
Summer Training day4 Sumdiv
Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the two natural原创 2017-08-07 19:23:22 · 150 阅读 · 0 评论 -
P3327 约数的个数和 [约数函数性质,数论分块]
P3327 约数的个数和题意d(x)d(x)d(x)为约数的个数,对于每个询问,回答∑i=1n∑j=1md(ij)\sum_{i=1}^n\sum_{j=1}^md(ij)∑i=1n∑j=1md(ij).题解这个题推得我头皮发麻,然后还没推出来,后来发现要做这题的先知道一个性质:d(ij)=∑x∣i∑y∣j[gcd(x,y)=1]d(ij)=\sum_{x|i}\sum_{y|j}[...原创 2018-11-05 22:23:02 · 913 阅读 · 0 评论