
迷之数论
文章平均质量分 83
Dillonh
博客园链接:http://www.cnblogs.com/Dillonh/
展开
-
POJ3090 Visible Lattice Points(欧拉函数)
欧拉函数欧拉函数的定义:1~N中与N互质的数的个数被称为欧拉函数,我们用phi[i]来记录与i互质的数的个数。根据算数基本定理(唯一分解定理),即N可以分解成N=p1^c1*p2^c2*…pm^cm,其中pi为质数可以推出phi[N]=N * (p1 - 1) / p1 * (p2 - 1) / p2*…(pm - 1) / pm。欧拉函数的部分性质:phi[n] = phi[n / p] * (...原创 2018-04-17 19:17:39 · 237 阅读 · 0 评论 -
Product Oriented Recurrence(Codeforces Round #566 (Div. 2)E+矩阵快速幂+欧拉降幂)
传送门题目fn=c2∗n−6fn−1fn−2fn−3\begin{aligned}&f_n=c^{2*n-6}f_{n-1}f_{n-2}f_{n-3}&\\\end{aligned}fn=c2∗n−6fn−1fn−2fn−3思路我们通过迭代发现fnf_nfn其实就是由cx1,f1x2,f2x3,f3x4c^{x_1},f_1^{x_...原创 2019-06-12 00:28:41 · 555 阅读 · 16 评论 -
Product(2019年西安邀请赛B+杜教筛)
题目链接传送门题面思路:我们先将公式进行化简:∏i=1n∏i=1n∏i=1nmgcd(i,j)[k∣gcd(i,j)]=m∑i=1n∑j=1n∑k=1ngcd(i,j)[k∣gcd(i,j)]\begin{aligned}&\prod_{i=1}^{n}\prod_{i=1}^{n}\prod_{i=1}^{n}m^{gcd(i,j)[k|gcd(i,j)]}&a...原创 2019-05-31 18:22:35 · 424 阅读 · 0 评论 -
洛谷P4213(杜教筛)
#include <bits/stdc++.h>using namespace std;typedef long long LL;const int maxn = 3e6 + 3;int t, n, cnt;bool v[maxn];short mu[maxn];int isp[maxn], phi[maxn];LL sum1[maxn];int sum2[maxn...原创 2019-05-30 18:23:11 · 231 阅读 · 0 评论 -
口算训练(唯一分解定理 + 二分+2018年女生赛)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6287题目:口算训练Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 177 Accepted Submission(s): 41Pro...原创 2018-05-29 14:51:28 · 422 阅读 · 0 评论 -
Super A^B mod C (快速幂+欧拉函数+欧拉定理)
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1759题目:Problem DescriptionGiven A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). InputThere ar...原创 2018-06-04 16:20:18 · 580 阅读 · 2 评论 -
Chinese Rings (九连环+矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2842题目:Problem DescriptionDumbear likes to play the Chinese Rings (Baguenaudier). It’s a game played with nine rings on a bar. The rules of this game are...原创 2018-04-29 22:22:20 · 343 阅读 · 0 评论 -
Plant (矩阵快速幂)
题目链接:http://codeforces.com/problemset/problem/185/A题目:Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle...原创 2018-04-29 22:10:40 · 351 阅读 · 0 评论 -
Tr A(矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1575题目:Problem DescriptionA为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。 Input数据的第一行是一个T,表示有T组数据。每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两...原创 2018-04-29 21:59:48 · 355 阅读 · 2 评论 -
湘潭校赛——又见斐波那契(矩阵快速幂)
题目链接:https://www.nowcoder.com/acm/contest/105/G思路:这题一看数据范围就知道是个矩阵快速幂,通过构造矩阵知我们需要的转移矩阵为下图形式,不过需要特判1然后输出的是n-1的结果哦,因为这个我本题WA了==!矩阵快速幂最难得就是构造矩阵,当矩阵构造出来之后基本上就好做了~代码实现如下:#include <cstdio>#include <...原创 2018-04-27 17:32:19 · 185 阅读 · 0 评论 -
CRB and Candies(组合数学+求逆元+lcm)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5407题目:Problem DescriptionCRB has N different candies. He is going to eat K candies.He wonders how many combinations he can select.Can you answer his que...原创 2018-05-04 14:51:55 · 299 阅读 · 0 评论 -
Exponial (欧拉定理+指数循环定理+欧拉函数+快速幂)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2021DescriptionEverybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing re...原创 2018-04-20 16:54:55 · 476 阅读 · 0 评论 -
Farey Sequence (欧拉函数+前缀和)
题目链接:http://poj.org/problem?id=2478DescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arrang...原创 2018-04-20 16:52:29 · 391 阅读 · 0 评论 -
The Sum of the k-th Powers()Educational Codeforces Round 7F+拉格朗日插值法)
题目链接传送门题面题意给你n,kn,kn,k,要你求∑i=1nik\sum\limits_{i=1}^{n}i^ki=1∑nik的值。思路根据数学知识或者说题目提示可知∑i=1nik\sum\limits_{i=1}^{n}i^ki=1∑nik可以被一个k+1k+1k+1次多项式表示。由拉格朗日插值法(推荐学习博客)的公式:L(x)=l(x)∑i=1k+2yiwix−xi,其中...原创 2019-07-14 11:45:36 · 178 阅读 · 0 评论