数论
小鱼爱吃火锅
多学习,多积累
展开
-
Divisors UVA - 294 (区间内约数最多的数和它因子的个数)
Mathematicians love all sorts of odd properties of numbers. For instance, they consider 945 to be aninteresting number, since it is the first odd number for which the sum of its divisors is larger th...原创 2019-10-22 16:40:39 · 199 阅读 · 0 评论 -
约数个数定理(求解因数的个数)
整数的唯一分解定理对于一个大于1正整数n可以分解质因数:约数个数定理则n的正约数的个数就是。其中a1、a2、a3…ak是p1、p2、p3,…pk的指数。定理简证编辑首先同上,n可以分解质因数:n=p1^a1×p2^a2×p3^a3*…*pk^ak,由约数定义可知p1^a1的约数有:p1^0, p1^1, p1^2......p1^a1 ,共(a1+1)个...原创 2019-10-22 16:15:37 · 4286 阅读 · 0 评论 -
不可摸数(因子和问题)
不可摸数 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19650Accepted Submission(s): 5154 Problem Description s(n)是正...原创 2019-10-22 15:53:15 · 284 阅读 · 0 评论 -
素数
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]....原创 2019-09-05 10:07:57 · 145 阅读 · 0 评论 -
标题:买不到的数目(数论)
小明开了一家糖果店。他别出心裁:把水果糖包成4颗一包和7颗一包的两种。糖果不能拆包卖。 小朋友来买糖的时候,他就用这两种包装来组合。当然有些糖果数目是无法组合出来的,比如要买 10 颗糖。 你可以用计算机测试一下,在这种包装情况下,最大不能买到的数量是17。大于17的任何数字都可以用4和7组合出来。 本题的要求就是在已知两个包装的数量时,求最大不能组合出...原创 2019-03-11 16:58:00 · 168 阅读 · 0 评论 -
标题:包子凑数(扩展欧几里得+完全背包)
小明几乎每天早晨都会在一家包子铺吃早餐。他发现这家包子铺有N种蒸笼,其中第i种蒸笼恰好能放Ai个包子。每种蒸笼都有非常多笼,可以认为是无限笼。每当有顾客想买X个包子,卖包子的大叔就会迅速选出若干笼包子来,使得这若干笼中恰好一共有X个包子。比如一共有3种蒸笼,分别能放3、4和5个包子。当顾客想买11个包子时,大叔就会选2笼3个的再加1笼5个的(也可能选出1笼3个的再加2笼4个的)。当然有时...原创 2019-02-26 23:00:39 · 425 阅读 · 0 评论 -
Candy Bags (矩形)
Gerald has n younger brothers and their number happens to be even. One day he bought n2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for ea...原创 2019-01-28 12:49:06 · 255 阅读 · 0 评论 -
Easy Math
Given nn integers a1,a2,…,ana1,a2,…,an, check if the sum of their square root a1−−√+a2−−√+⋯+an−−√a1+a2+⋯+an is a integer.InputThe input consists of multiple tests. For each test:The first l...原创 2019-01-28 19:35:19 · 370 阅读 · 0 评论 -
求三个数的最小公倍数
方法一:和求两个数的最小公倍数一样:两个数的积/最大公约数( c=a*b/gcd(a,b) )#include<iostream>#include<cstdio>using namespace std;int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main()...原创 2019-01-24 22:02:36 · 686 阅读 · 0 评论 -
费马定理
费马小定理:假如p是质数,且gcd(a,p)=1,那么 a^(p-1)≡1(mod p)。即:假如a是整数,p是质数,且a,p互质(即两者只有一个公约数1),那么a的(p-1)次方除以p的余数恒等于1。费马大定理:x^n + y^n = z^n(n >2时,没有正整数解) ...原创 2018-11-27 20:21:52 · 4935 阅读 · 0 评论 -
Diophantus of Alexandria (唯一分解求一个数的因子数)
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral values. In honor of him,...原创 2018-11-27 20:15:50 · 150 阅读 · 0 评论 -
Deciphering Password (积性函数+唯一分解定理+质因数分解)
Xiaoming has just come up with a new way for encryption, by calculating the key from a publicly viewable number in the following way: Let the public key N = A B, where 1 <= A, B <= 1000000, and...原创 2018-11-26 21:37:13 · 347 阅读 · 1 评论 -
积性函数+唯一分解定理+质因数分解
积性函数定义: 积性函数:指对于所有互质的整数a和b有性质f(ab)=f(a)f(b)的数论函数。 完全积性函数:对于任意整数a和b有性质f(ab)=f(a)f(b)的数论函数。积性函数性质: 1.若将n表示成质因子分解式,,则有 2.若f为积性函数且有 ,则f为完全积性函数。 唯一分解定理: 定义:任何大于1的自然数...原创 2018-11-26 21:06:12 · 298 阅读 · 0 评论 -
GCD (欧拉函数)
The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6. (a,b) can be easily found by the ...原创 2018-11-29 16:16:48 · 243 阅读 · 0 评论 -
欧拉函数
定义: 在数论中,对于正整数N,小于或等于N 且与N互质的正整数(包括1)的个数,记作φ(n)。 φ函数的值: φ(x)=x(1-1/p(1))(1-1/p(2))(1-1/p(3))(1-1/p(4))…..(1-1/p(n)) 其中p(1),p(2)…p(n)为x 的所有质因数; x是正整数; φ(1)=1(唯一和1互质的数,且小于等于1)。...原创 2018-11-29 16:02:37 · 157 阅读 · 0 评论 -
欧几里德算法,扩展算法
欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。公式描述:gcd(a,b)=gcd(b,a mod b)代码:int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);} 扩展欧几里德算法对于不完全为 0 的非负整数 a,b,gcd(a,b)表示 a,b 的最大公约数,必然...原创 2018-11-24 11:08:20 · 165 阅读 · 0 评论 -
线性欧拉筛法
可以借鉴这篇博客理解:https://blog.csdn.net/qq_39763472/article/details/82428602#comments合数指自然数中除了能被1和本身整除外,还能被其他数(0除外)整除的数时间复杂度O(n)每个合数只会被他的最小的质因子筛去。#include<iostream>#include<cmath>#inc...原创 2018-11-24 10:45:57 · 162 阅读 · 0 评论