基础数论
文章平均质量分 81
wust_cyl
在非洲,瞪羚每天早上醒来时,他知道自己必须跑的比最快的狮子还快,否则就会被吃掉.狮子每天早上醒来时,他知道自己必须追上跑得最慢的瞪羚,否则就会被饿死.不管你是狮子还是瞪羚,当太阳升起时,你最好开始奔跑
展开
-
HDU 3988(数论)
问题描述:iSea is tired of writing the story of Harry Potter, so, lucky you, solving the following problem is enough. InputThe first line contains a single integer T, indicating the number of t原创 2018-02-07 22:06:58 · 289 阅读 · 0 评论 -
lightoj-1289(数论+素数打表)
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 (≤ 10000),...原创 2017-08-16 19:51:15 · 646 阅读 · 1 评论 -
hdu-5446(中国剩余定理+lucas)
Problem DescriptionOn the way to the next secret treasure hiding place, the mathematician discovered a cave unknown to the map. The mathematician entered the cave because it is there. Somewhere deep i...原创 2017-08-18 09:49:01 · 503 阅读 · 0 评论 -
poj-1284(欧拉函数+原根)
问题描叙:We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecuti...原创 2017-08-23 09:37:31 · 874 阅读 · 0 评论 -
poj-3696(欧拉定理+推导)
DescriptionChinese 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 ...原创 2017-08-22 10:05:06 · 599 阅读 · 0 评论 -
poj-2480(数论+积性函数性质)
DescriptionLongge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a problem comes: Given an integer N(1 < N < ...原创 2017-08-21 20:01:11 · 790 阅读 · 1 评论 -
bzoj-3884(指数循环节)
Description根据一些书上的记载,上帝的一次失败的创世经历是这样的:第一天, 上帝创造了一个世界的基本元素,称做“元”。第二天, 上帝创造了一个新的元素,称作“α”。“α”被定义为“元”构成的集合。容易发现,一共有两种不同的“α”。第三天, 上帝又创造了一个新的元素,称作“β”。“β”被定义为“α”构成的集合。容易发现,一共有四种不同的“β”。第四天, 上帝创造了新的元素“γ”,“γ”被定...原创 2017-08-21 14:56:12 · 358 阅读 · 0 评论 -
bzoj-2186 (欧拉函数+费马小定理求逆元)
Description大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票。房地产第一大户沙拉公主决定预测一下大富翁国现在所有真钞票的数量。现在,请你帮助沙拉公主解决这个问题,由于可能张数非常大,你只需计算出对R取模后的答案即可。R是一个质数。Input第一行为两个整数T,R。R<=10^9+10,T<=10...原创 2017-08-21 11:17:18 · 433 阅读 · 0 评论 -
hdu -2837(指数循环节+欧拉函数)
Problem DescriptionAssume 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).InputThe first line cont...原创 2017-08-20 09:36:29 · 651 阅读 · 0 评论 -
hdu-3307 (欧拉定理+推导)
Problem Descriptionan = X*an-1 + Y and Y mod (X-1) = 0.Your task is to calculate the smallest positive integer k that ak mod a0 = 0.InputEach line will contain only three integers X, Y, a0 ( 1 < X ...原创 2017-08-20 18:44:32 · 834 阅读 · 1 评论 -
求1到n里面约数最多的数的约数个数
题目:求1到n里面约数最多的数的约数个数分析:首先明白一个数的约数的求法。根据约数和定理:对于一个大于1正整数n可以分解质因数:n=p1^a1*p2^a2*p3^a3*…*pk^ak,则由约数个数定理可知n的正约数有(a₁+1)(a₂+1)(a₃+1)…(ak+1)个,暴力算出每一个数的约数的个数,超时!根据唯一分解定理,我们知道每一个数都可以用质因子的积表示,而约数的个数只与指数原创 2018-03-31 23:49:22 · 5421 阅读 · 1 评论 -
poj-3604(数论+推导)
问题描述:Professor Ben is an old stubborn man teaching mathematics in a university. He likes to puzzle his students with perplexing (sometimes boring) problems. Today his task is: for a given integer N, a...原创 2017-08-29 19:57:38 · 490 阅读 · 0 评论 -
POJ - 3993(数论)
问题描述:Any positive integer v can be written as p 1 a1*p 2 a2*...*p n an where p i is a prime number and ai ≥ 0. For example: 24 = 2 3*3 1. Pick any two prime numbers p 1 and p 2 where p 1 = p 2. Imagin...原创 2017-08-31 19:04:24 · 290 阅读 · 0 评论 -
hdu 1695(欧拉公式,容斥原理||莫比乌斯反演)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe...原创 2017-08-13 20:47:41 · 593 阅读 · 1 评论 -
CodeForces 687B(剩余定理)
问题描述:Today Pari and Arya are playing a game called Remainders.Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value . There are n ancient numbers c1, c2, ....原创 2017-11-06 23:21:56 · 467 阅读 · 0 评论 -
hdu-1370(中国剩余定理余数互质)&&hdu-1573(中国剩余定理余数不互质)
中国剩余定理是用来求解一次同余方程组问题的重要方法,是数论的一个重要定理。对于同余方程组: x=a1 mod n1 x=a2 mod n2 ...................... x=ak mod nk我们就可以利用中国剩余定理来求解x!下面我们分俩种情况来求解:1 当n1 n2 nk俩俩互质时的情况:我们由方程组第一个式子可以得到:x1=n1...原创 2017-08-14 20:55:16 · 307 阅读 · 0 评论 -
hdu-1452(约数和定理+求逆元)
问题描述:Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an exampl...原创 2017-08-24 09:29:25 · 669 阅读 · 0 评论 -
hdu-2142(扩展欧几里得解不定方程)
DescriptionMs. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine. For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can p...原创 2017-08-16 17:04:54 · 412 阅读 · 0 评论 -
hdu-4596(扩展欧几里得解一次不定方程)
Problem DescriptionIn the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any more and the Rapture finally comes in. Fortunately people h...原创 2017-08-16 14:26:46 · 360 阅读 · 0 评论 -
hdu-3270(扩展欧几里得)
Problem DescriptionWe will consider a linear Diaphonic equation here and you are to find out whether the equation is solvable in non-negative integers or not.Easy, is not it?InputThere will be multipl...原创 2017-08-15 11:14:55 · 508 阅读 · 0 评论 -
hdu-2669(扩展欧几里得)
Problem DescriptionGirls are clever and bright. In HDU every girl like math. Every girl like to solve math problem!Now tell you two nonnegative integer a and b. Find the nonnegative integer X and inte...原创 2017-08-15 09:30:44 · 450 阅读 · 0 评论 -
hdu 3823(素数)
问题描述:Besides the ordinary Boy Friend and Girl Friend, here we define a more academic kind of friend: Prime Friend. We call a nonnegative integer A is the integer B’s Prime Friend when the sum of A and...原创 2018-02-07 20:04:48 · 439 阅读 · 1 评论 -
Codeforces 155D(分解质因子+预处理)
问题描述:By 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from 1 to n. However, scientists did not know what activati...原创 2017-12-21 10:17:12 · 320 阅读 · 0 评论 -
基础数论-扩展欧几里得算法
首先我们先了解欧几里得算法求俩个数a,b的最大公约数gcd(a,b)根据贝祖定理得,gcd(a,b)=gcd(b,a-b),(a>b) 直到b为0时,a就是答案,但是这样时间复杂度有点高,因为a-b并不能保证一定大于b,所以我们又会做一次同样操作,即gcd(a,b)=gcd(b,a mod b)。时间复杂度log N代码如下:int gcd(int a,int b){ return...原创 2018-05-26 00:50:00 · 313 阅读 · 0 评论