数论
文章平均质量分 79
Big_Rui
这个作者很懒,什么都没留下…
展开
-
GCD - Extreme 欧拉函数
Given the value of N, you will have to find the value of G. The definition of G is given below:G =i∑i=1j∑≤Nj=i+1GCD(i, j)Here GCD(i, j) means the greatest common divisor of integer原创 2017-08-01 09:28:13 · 678 阅读 · 0 评论 -
Professor Ben 唯一分解定理:因子的因子个数
题意:一个数N,它的因子为a1,a2....ai...an,求每一个因子的因子个数的三次方;例如4的因子1,2,4。1的因子个数为1,2的因子个数为2,4的因子个数为3结果bns=1^3+2^3+3^3=36;思路:唯一分解定理(自己去网上了解)求每个素数因子的指数例如36=2^2*3^2;2的指数是2,意味着有三种组合,2^0,2^1,2^2,每一种组合能提供(1+0),(1原创 2017-08-29 20:14:08 · 579 阅读 · 0 评论 -
Prime Distence 大数据区间筛素数
题意:给定两个数1,求区间内距离最小和距离最大的两个素数难点:数据太大,肯定不能正常打表,但是r-l思路:先打一部分表,大概N=1e5就够了,然后从所给区间[l,r],l(接下来的话和题解无关:很郁闷一点就是因为不同的下标计算方法RE,现在还是没理解原理for(int i=0;i<=r-l;++i)if(pis[i]) bns[++cnt]=i+l;改成for(int i=l;i<=原创 2017-08-23 21:10:08 · 298 阅读 · 0 评论 -
Death to Binary? 模拟+斐波那契进制数标准式
题意:用斐波那契数来计数,一个字符串s,字符串中只有0或1,f[i]代表第i个斐波那契数0代表0*f[i],1代表1*f[i],从字符串最右边开始,第i个字符代表f[i],例如1010=0*f[0]+1*f[1]+0*f[2]+1*f[3]=0+2+0+5=7;标准字符串:字符串中任意两个1不相邻难点:将所给字符串转化成标准字符串思路:因为任一斐波那契数都是前两个相加,因此从小原创 2017-08-21 20:52:07 · 508 阅读 · 0 评论 -
Help Hanzo 素数打表进阶(大数据区间打表)
题意:求a~b之间的素数;(1难点:数据太大,素数打表会TLE,枚举会MLE;解题关键:b-a方法:素数打表小部分(1e6),然后用已打表素数去拓展所给区间的素数,用v[j-a](a#include#include#include#includeusing namespace std;typedef long long ll;const int N=1e6+5;int原创 2017-08-21 15:11:43 · 611 阅读 · 0 评论 -
Large Division 同余定理
题意:一个非常大的数a是否能整除b别人都说是同余,我上网看定理没研究出来啥,可能是推出来的结论,记住就好ans=(ans*10+a[i]-'0')%b,i从0-n-1,最后结果为0就是能整除注意:b用long long 不然会炸,不知道为什么,希望大佬看的时候评论告诉我;#include#include#includeusing namespace std;typede原创 2017-08-13 10:06:29 · 263 阅读 · 0 评论 -
The Super Powers
题意:一个数能化成两个不同的数的平方数,原创 2017-08-19 20:53:24 · 475 阅读 · 0 评论 -
Lengthening Sticks 组合数+容斥原理
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be inc原创 2017-07-28 08:36:02 · 464 阅读 · 0 评论 -
Harmonic Number 调和级数的欧拉公式
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer T原创 2017-08-04 10:46:06 · 1512 阅读 · 0 评论 -
Prime Time 素数筛选+玄学1e-8
Euler is a well-known matematician, and, among many other things, he discovered that the formulan2 + n + 41 produces a prime for 0 ≤ n Even though this formula doesn’t always produce a prime, it原创 2017-08-03 23:04:23 · 697 阅读 · 0 评论 -
How Many Sets
Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is a subset of S, (1 InputThe input contains multiple cases, each case have 2 integ原创 2017-07-26 09:42:05 · 451 阅读 · 0 评论 -
Goldbach`s Conjecture 素数筛选
Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [1]原创 2017-08-03 10:02:27 · 655 阅读 · 0 评论 -
Mysterious Bacteria 素因子分解(唯一分解定理)
题意:(题目在最后)给你一个整数n,让你求满足b^p=x的最大的p,例如72=2^3*3^2;结果是1;因为只有72^1=72;216=2^3*3^3=6^3,结果是3;利用 唯一分解定理x=p1^e1*p2^e2*......pi^ei,存下每一个指数,再求最大公约数,得到答案;注意:两个点1: n有可能是负的,这时候先把n变成正数求,因为只有b^奇数才可能为负数,(n=原创 2017-08-10 09:53:38 · 561 阅读 · 0 评论 -
Leading and Trailing 快速幂和cmath函数(modf函数,log10函数,pow函数)
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 n原创 2017-08-03 08:39:48 · 530 阅读 · 0 评论 -
Perfect Squares 费马小定理求乘法逆元k=b^(p-2)
Problem DescriptionA number x is called a perfect square if there exists an integer b satisfying x=b^2. There are many beautiful theorems about perfect squares in mathematics. Among which, Pythago原创 2017-07-24 15:36:51 · 689 阅读 · 0 评论 -
Aladdin and the Flying Carpet 唯一分解定理
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter to a ma原创 2017-08-02 16:04:09 · 385 阅读 · 0 评论 -
LCM 埃拉托斯特尼素数筛法+位图改进
Given an integer n, you have to findlcm(1, 2, 3, ..., n)lcm means least common multiple. For example lcm(2, 5, 4) = 20, lcm(3, 9) = 9, lcm(6, 8, 12) = 24.InputInput starts with an integer T (≤原创 2017-08-16 16:33:18 · 561 阅读 · 0 评论 -
Primitive Root 原根
题意:给定模P,n个c,判断c是否是p的原根,《数论概论》中“幂模p与原根”一章中有提到阶的概念: 如果gcd(c,p)=1,则a模p的阶是指使得a^d=1(mod p)的最小指数d(d>=1); 例如2、3、4、5、6模7的阶分别是3、6、3、6、2。重要性质:一个数a模p的阶e总能整除p-1。 所以可以枚举p-1的所有因子factor (不包括p-1),如果存原创 2017-12-04 01:12:53 · 1196 阅读 · 0 评论