
数论基础
xiao_you_you
这个作者很懒,什么都没留下…
展开
-
N - Trailing Zeroes (III) LightOJ - 1138
题目大意很好懂,就是求N!的0的个数思路:首先考虑到乘积得到0,是由若干2*5构成。这是后问题就转化成我们找N!中有多少2和5,又因为2的个数一定比5多,那么我们只需要找到5的个数就好。那么5的个数怎么求呢 下面给出求法的代码:(不要暴力去搜,会超时的)int Judge(int n){ int ans = 0; while(n){ ans += n/5...原创 2018-10-23 13:04:57 · 195 阅读 · 1 评论 -
Problem G. Pyramid ICPC2018 南京站
思路: 考虑到每次必须在o(1)的复杂度下计算出答案,该题肯定就是推出一个关于n的一元几次式。因此打表找规律。打表后得到1,5,15,35,70,126,210..作差 4, 10, 20, 35, 56, 84作差 6, 10, 15, 21, 28再作差 4,5,6,7再做差1,1,1,1共做差四次 因此设 f(n)=a∗n4+b∗n3+c∗n2+d∗n+e...原创 2019-10-04 16:02:26 · 549 阅读 · 0 评论 -
BZOJ1013 (高斯消元模版题)
#include<iostream>#include<cstring>#include<cstdio>#include<cmath>#define ll long longusing namespace std;double a[20][20],b[20],c[20][20];int n;int main(){ cin>...原创 2019-09-02 21:16:04 · 190 阅读 · 0 评论 -
中国剩余定理模版
#include<iostream>#include<cstdio>#define ll long longusing namespace std;//扩展欧几里得算法void gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(b==0){ d=a; x=1; ...原创 2019-08-31 21:05:43 · 120 阅读 · 0 评论 -
扩展中国剩余定理模版
#include <cstdio>using namespace std;typedef long long ll;ll exgcd(ll a,ll b,ll &x,ll &y){ if(!b)return x=1,y=0,a; ll d=exgcd(b,a%b,x,y),z=x; x=y,y=z-a/b*y; return d...原创 2019-08-31 20:59:48 · 154 阅读 · 0 评论 -
欧拉函数模版
const int N=41000;long long phi[N];void euler(long long n){ for(long long i=2; i<=n; i++) phi[i]=i; for(long long i=2; i<=n; i++) if (phi[i]==i) for(long ...原创 2019-07-30 11:20:07 · 82 阅读 · 0 评论 -
2019年牛客多校第一场B题 Integration
思路:将进行裂项化简得: 由于则原式等于求解该式即可#include<iostream>#include<cstdio>#define ll long long#define mod 1000000007using namespace std;ll n,a[1008611],num[1008611];long long fast_mod(lon...原创 2019-07-19 12:35:15 · 144 阅读 · 0 评论 -
C. Neko does Maths(code forces)
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.Neko has two integers原创 2019-04-26 09:56:24 · 784 阅读 · 0 评论 -
Master of Random
Hakase provides Nano with a problem. There is a rooted tree with values on nodes. For each query,you are asked to calculate the sum of the values in the subtree. However, Nano is a rookie so she decid...原创 2019-04-08 15:22:57 · 242 阅读 · 0 评论 -
Master of Phi(数论)
You are given an integer n. Please output the answer of modulo 998244353. n is represented in the form of factorization.φ(n) is Euler’s totient function, and it is defi ned more formally as the num...原创 2019-04-07 11:10:19 · 358 阅读 · 0 评论 -
包子凑数 (exgcd+dp)
问题描述 小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子。每种蒸笼都有非常多笼,可以认为是无限笼。 每当有顾客想买X个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的...原创 2019-03-25 20:54:48 · 116 阅读 · 0 评论 -
10297: Podzielno
题目描述B进制数,每个数字i(i=0,1,...,B-1)有a[i]个。你要用这些数字组成一个最大的B进制数X(不能有前导零,不需要用完所有数字),使得X是B-1的倍数。q次询问,每次询问X在B进制下的第k位数字是什么(最低位是第0位)。 输入第一行包含两个正整数B(2<=B<=10^6),q(1<=q<=10^5)。第二行包含B个正整数a[0],a[1]...原创 2018-12-19 16:36:43 · 111 阅读 · 0 评论 -
The Luckiest number POJ - 3696 (欧拉定理)
题目大意:对于给定的整数L,找出L能整除最短的全8序列的长度,做为Bob的幸运数字。解析:一开始做这个题的时候直接莽夫式做法 ,枚举8的位数,交一发直接wa,想想也是,没给8的位数的上限,暴力枚举8的话肯定要爆longlong的。 。。正确的做法居然是用欧拉定理。我们可以通过题意列出下式:8/9 * (10^x-1)=L * p 根据欧拉定理我们知道:10^Φ(m)≡1(mod m)。...原创 2018-10-30 17:01:17 · 133 阅读 · 0 评论 -
Problem J. Prime Game 2019南京站ICPC
思路:计算第i个数中包含的每个素数对答案的贡献(其贡献的区间为[i,i+1,i+2...n],则贡献为n-i+1)#include<bits/stdc++.h>#define ll long longusing namespace std; int n,a[1000010];vector<int> v[1000010]; int main(){ ...原创 2019-10-04 16:14:34 · 288 阅读 · 0 评论