![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
mmk27
这个作者很懒,什么都没留下…
展开
-
1225 D. Power Products 哈希
题目链接:http://codeforces.com/problemset/problem/1225/D题意:有多少种组合方式,使得两个数相乘 能写成 x^k 的形式题解:首先x^k,x的每个素因子的数目都是k的倍数,那么我们就对于每个数的素因子个数哈希一下,对于每个数求值的时候,找到能使他的每个素因子个数为k的倍数的哪些数。#include <bits/stdc++.h>...原创 2019-10-31 10:49:41 · 236 阅读 · 0 评论 -
HDU - 4215 Number Theory? 打表
In number theory, for a positive number N, two properties are often mentioned, one is Euler's function, short for E(N), another is factor number, short for F(N).To be more precise for newbie, here we...原创 2018-12-23 14:44:53 · 264 阅读 · 0 评论 -
HDU - 4497 GCD and LCM 数论
Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L? Note, gcd(x, y, z) means the greatest common d...原创 2019-01-01 17:41:37 · 122 阅读 · 0 评论 -
HDU - 5145 NPY and girls 莫队算法+逆元
题目链接:https://cn.vjudge.net/problem/HDU-5145题意:区间[l, r] 内的数全排列能得到多少种不同的排列题解:假设sum是当前的数量,再加上一个就是乘上sum+1,乘上这个数+1 的数量的逆元,减去一个是乘上sum的逆元,乘上这个数的数量#include<bits/stdc++.h>using namespace std;typ...原创 2019-05-14 17:21:13 · 156 阅读 · 0 评论 -
HDU - 2879 HeHe 线性筛
题目链接:https://cn.vjudge.net/problem/HDU-2879题意:X^2≡X(mod N) where x∈[0,N-1]的数量为 He[N] HeHe[N]=He[1]*……*He[N] 求HeHe[n]%m题解:打表可以看出,He[i] = 2^质因子数目,之前先求出了欧拉函数做的,但是超时,所以,要用线性筛来先把素数筛出来,通过枚举素因子来做就...原创 2019-06-25 15:09:56 · 222 阅读 · 0 评论 -
1040 最大公约数之和 欧拉函数
题目链接:http://www.51nod.com/Challenge/Problem.html#!#problemId=1040题意:给出一个n,求1-n这n个数,同n的最大公约数的和。比如:n = 61,2,3,4,5,6 同6的最大公约数分别为1,2,3,2,1,6,加在一起 = 15题解:枚举他的因子p,gcd为p时的种类数为(n / p) 的欧拉函数#include&l...原创 2019-06-25 15:55:04 · 201 阅读 · 0 评论 -
吉首大学2019年程序设计竞赛(重现赛)
题目链接:https://ac.nowcoder.com/acm/contest/992#question链接:https://ac.nowcoder.com/acm/contest/992/A来源:牛客网A、SARS病毒时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述目...原创 2019-07-14 17:12:44 · 924 阅读 · 0 评论 -
杜教筛 P4213 【模板】(Sum)
杜教筛讲解:https://www.cnblogs.com/peng-ym/p/9446555.html常见积性函数μ(n)——莫比乌斯函数。 φ(n)——欧拉函数。 d(n)——约数个数。 σ(n)——约数和函数。(PS:接下来列举的是完全积性函数)ϵ(n)——元函数。我们只需要知道ϵ(n)=[n=1] I(n)——恒等函数。所谓恒等就是这个函数的值恒为11。 id(n...原创 2019-07-01 11:38:38 · 230 阅读 · 0 评论 -
HDU - 4812 D Tree 树分治好题+逆元+HASH
题目链接:https://cn.vjudge.net/problem/HDU-4812题意:找到两点路径上点乘积%mod=k,要求字典序最小题解:之前写的都是容斥写的,也就是先处理根,然后减去孩子,但是这个要求明确找到两点,所以就不能这么搞了。因此要一个分支一个分支的处理,mp[i]记录下之前分支,根节点到某一点路径上的点乘积为i时的最小节点编号,因为a * b % mod = k, 已知...原创 2019-07-19 17:13:30 · 167 阅读 · 0 评论 -
2019 杭电多校 HDU - 6623 Minimal Power of Prime 因子幂最小
题目链接:https://vjudge.net/problem/HDU-6623题意:输出n,所以质因子幂的最小值题解:先处理1e4以内的质数,也就1000多个,然后如果没有除尽的话,因子最多也就4个了,所以幂数大于1的情况有p1^4,p1^3, p1^2 , p1^2*p2^2, 对于其他情况肯定有幂为1的。#include<cstdio>#include<c...原创 2019-07-31 19:11:29 · 1080 阅读 · 8 评论 -
2019牛客暑期多校训练营(第五场)B generator 1 十进制快速幂 / 循环节 积性
链接:https://ac.nowcoder.com/acm/contest/885/B?&headNav=acm&headNav=acm&headNav=acm来源:牛客网generator 1时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述Yo...原创 2019-08-01 22:49:37 · 355 阅读 · 0 评论 -
CodeForces - 1228C Primes and Multiplication 数贡献
题目链接:https://vjudge.net/problem/CodeForces-1228C题解:把x的每个质因子找出来,计算n!对每个因子的贡献#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod = 1e9 + 7;const int N = 1e5 + 10...原创 2019-10-05 13:26:30 · 302 阅读 · 0 评论 -
Gym - 101972I Secret Project 组合数+思维
There are n students working on a secret project, this project is very important and unique, so they decided to keep it safe, and protect it from leakage.The students will put all the project's docu...原创 2018-12-16 12:14:36 · 535 阅读 · 0 评论 -
小乐乐学数学 哈理工第八届程序设计竞赛同步赛(高年级)H 树状数组 + 离线 + 互质区间
链接:https://ac.nowcoder.com/acm/contest/301/H来源:牛客网题目描述小乐乐上了一节数学课,数学老师讲的很好,小乐乐听的也如痴如醉。小乐乐听了老师的讲解,知道了什么是素数,现在他想做几个习题。现在题目来了:首先我们先定义孤独的数:在一个区间中的一个数字x,如果他与这个区间中的任何数都互质,那么他就是孤独的数。我们给定一个序列,然后接下来会有多...原创 2018-12-05 16:34:02 · 286 阅读 · 0 评论 -
CodeForces - 1055C Lucky Days
Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are ...原创 2018-11-15 16:20:52 · 381 阅读 · 0 评论 -
hdu -2837-Calculation
Assume that f(0) = 1 and 0^0=1. f(n) = (n%10)^f(n/10) for all n bigger than zero. Please calculate f(n)%m. (2 ≤ n , m ≤ 10^9, x^y means the y th power of x). Input The first line contains a single p...原创 2018-07-26 21:16:13 · 266 阅读 · 1 评论 -
求n以内与n互质的和 与n互质的平方和
结论:gcd(n,m)=1,那么gcd(n,n-m)=1;求和的时候 ph(n)即可 sum = ph(n)*n/2;#include <bits/stdc++.h> using namespace std;typedef long long ll;ll euler(ll n){ ll ans = n; for(int i = 2; i * i &l...原创 2018-09-09 10:46:11 · 316 阅读 · 0 评论 -
HDU - 6216 A Cubic number and A Cubic Number 立方差为素数 两数相差一定为1 相差为1的立方差不定为素数
A cubic number is the result of using a whole number in a multiplication three times. For example, 3×3×3=273×3×3=27 so 2727 is a cubic number. The first few cubic numbers are 1,8,27,641,8,27,64 and 12...原创 2018-09-13 14:11:07 · 233 阅读 · 0 评论 -
数论一些小总结
1.对于任意一个素数p, n!中含有p的个数为 (n/p + n/p^2 + n/p^3 + ......).2.c(n,k) = n! / ( k! * (n-k)! ).3.c(n,k)=(n-k+1)/k*c(n,k-1).4.任意一个数n可以写成若干个素数的乘积,即 p1^a1 * p2^a2*......*pn^an, 它的的约数的个数为 (a1+1)*(a2+1)*.....原创 2018-09-14 11:55:01 · 807 阅读 · 0 评论 -
LightOJ - 1336 Sigma Function 平方数约数和定为奇数
Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4...原创 2018-09-14 12:43:07 · 165 阅读 · 0 评论 -
LightOJ - 1282 Leading and Trailing 前3位
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the num...原创 2018-09-14 13:32:28 · 111 阅读 · 0 评论 -
HDU - 5476 Explore Track of Point 计算几何
In Geometry, the problem of track is very interesting. Because in some cases, the track of point may be beautiful curve. For example, in polar Coordinate system, ρ=cos3θρ=cos3θ is like rose, ρ=1−sinθ...原创 2018-09-14 16:35:21 · 111 阅读 · 0 评论 -
51Nod - 1189 阶乘分数 阶乘素因子分解
1/N! = 1/X + 1/Y (0<x<=y),给出N,求满足条件的整数解的数量。例如:N = 2,1/2 = 1/3 + 1/6,1/2 = 1/4 + 1/4。由于数量可能很大,输出Mod 10^9 + 7。Input输入一个数N(1 <= N <= 1000000)。Output输出解的数量Mod 10^9 + 7。Sample Input...原创 2018-10-22 23:50:42 · 208 阅读 · 0 评论 -
Gym - 100548F Color 组合数+容斥
题意:给你N朵花,M种颜料(n,m<=1e9),要求给所有花染色,且相邻的花不能用同样的颜色,求出最后恰好用了k种颜料的方案数(k<=1e5)题解:当我们用至少k中染色的时候 f[k] = k*(k-1)^(n-1) 其中包括了 至少k-1中的,我们需要减去C(k,k-1)*f[k-1] ,但是很明显我们多减了一次至少f[k-2]次的,举个栗子:假设有1 2 3 4 5,我...原创 2018-10-30 14:28:21 · 194 阅读 · 0 评论 -
HDU 5667 Sequence 矩阵快速幂 + 费马小定理
olion August will eat every thing he has found. Now there are many foods,but he does not want to eat all of them at once,so he find a sequence.fn=⎧⎩⎨⎪⎪1,ab,abfcn−1fn−2,n=1n=2otherwise He give...原创 2018-11-08 09:57:24 · 160 阅读 · 0 评论 -
poj3696 The Luckiest numbe
Chinese people think of ‘8’ as the lucky digit. Bob also likes digit ‘8’. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positiv...原创 2018-07-26 20:25:22 · 189 阅读 · 0 评论