
数论
RPG_Zero
春日雨,夏蝉鸣,明天是个好天气。
秋风起,雪花轻,海底看不见四季。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ 3181 Dollar Dayz 完全背包 高精度dp 大数
DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer Joh...原创 2019-08-16 15:21:56 · 202 阅读 · 0 评论 -
牛客网 又见斐波那契 矩阵快速幂
题目链接链接:https://ac.nowcoder.com/acm/contest/105/G来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述这是一个加强版的斐波那契数列。给定递推式求F(n)的值,由于这个值可能太大,请对10^9+7取模。输入描述:第一行是一个...原创 2019-08-30 11:01:03 · 251 阅读 · 0 评论 -
POJ 3233 Matrix Power Series 矩阵快速幂
题目链接Matrix Power SeriesTime Limit: 3000MS Memory Limit: 131072KDescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A^2 + A^3 + … + A^k.InputThe input contains exac...原创 2019-08-30 15:09:12 · 226 阅读 · 0 评论 -
快速幂小结 快速幂运算+矩阵快速幂
目录快速幂运算矩阵快速幂快速幂运算快速幂运算算法——反复平方法算出数 x 的 n 次方的值。普通求n次方的算法为o(n) 效率较低。下面来考虑加速幂运算的方法,如果 n = 2^k,可以将其表示为:xn = ((x2 )2 )…只需要k次平方运算即可轻松求得。由此我们可以联想到,先将n表示为2的幂的和。n = 2k1+ 2k2 + 2k3 + …就有xn = x2k1 + ...原创 2019-08-30 15:50:32 · 404 阅读 · 0 评论 -
POJ 1001 Exponentiation 求高精度幂
题目链接DescriptionProblems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many...原创 2019-08-31 14:57:14 · 224 阅读 · 0 评论 -
牛客网 a+b 九度教程第60题 高精度整数相加
题目链接时间限制:1 秒 内存限制:32 兆 特殊判题:否题目描述: 实现一个加法器,使其能够输出 a+b 的值。输入: 输入包括两个数 a 和 b,其中 a 和 b 的位数不超过 1000 位。输出:可能有多组测试数据,对于每组数据,输出 a+b 的值。样例输入:2 610000000000000000000 10000000000000000000000000000000样...原创 2019-08-31 18:54:42 · 262 阅读 · 0 评论 -
求n的阶乘小结 大数与普通整数相乘 九度教程第61题以及求10000以内n的阶乘
目录题型介绍例题1 求1000以内N的阶乘例题2 求10000以内N的阶乘题型介绍有这么一类题目,要求求解n以内的阶乘,由于最终结果往往非常巨大,不能用常用的数据类型来保存,这时候我们便可以选择使用数组来保存这样的大整数。求阶乘的过程中,每次乘法运算可以视为一个大整数与一个普通整数相乘,那么我们便可以让这一个普通整数依次与大整数的每一位相乘,同时注意处理好进位关系。核心代码:int nu...原创 2019-08-31 19:36:32 · 354 阅读 · 0 评论 -
进制转换 N的阶乘 a+b 高精度整数运算小结 高精度整数乘普通整数 高精度整数间求和、差 高精度整数除以普通整数 高精度整数对普通整数求模
目录简介高精度整数加法例题 a+b高精度整数减法高精度整数乘法(高精度整数乘普通整数)例题 N的阶乘 求1000以内n的阶乘高精度整数除法、高精度整数对普通整数求模例题 进制转换 (九度教程第62题)注意事项简介有这么一类整数,它们的数值非常巨大以致于我们不能使用任何内置整数类型来进行保存。面对这种情况,我们常用一个结构体来保存一个高精度整数:struct bigInt {//高精度整数结构...原创 2019-09-01 15:54:21 · 855 阅读 · 0 评论 -
九度教程第63题 牛客网 浮点数相加
题目描述:求2个浮点数相加的和题目中输入输出中出现浮点数都有如下的形式:P1P2…Pi.Q1Q2…Qj对于整数部分,P1P2…Pi是一个非负整数对于小数部分,Qj不等于0输入:对于每组案例,第1行是测试数据的组数n,每组测试数据占2行,分别是两个加数。每组测试数据之间有一个空行,每行数据不超过100个字符输出:每组案例是n行,每组测试数据有一行输出是相应的和。输出保证一定是...原创 2019-09-01 21:00:47 · 1062 阅读 · 5 评论 -
大整数排序 (九度教程第64题) 高精度整数比较大小
题目链接题目描述:对N个长度最长可达到1000的数进行排序。输入:输入第一行为一个整数N,(1<=N<=100)。接下来的N行每行有一个数,数的长度范围为1<=len<=1000。每个数都是一个正数,并且保证不包含前缀零。输出:可能有多组测试数据,对于每组数据,将给出的N个数从小到大进行排序,输出排序后的结果,每个数占一行。样例输入:31111111...原创 2019-09-01 21:35:57 · 735 阅读 · 1 评论 -
10进制 vs 2进制 九度教程第65题 高精度运算
题目链接对于一个十进制数A,将A转换为二进制数,然后按位逆序排列,再转换为十进制数B,我们称B为A的二进制逆序数。 例如对于十进制数173,它的二进制形式为10101101,逆序排列得到10110101,其十进制数为181,181即为173的二进制逆序数。输入描述:一个1000位(即10^999)以内的十进制数。输出描述:输入的十进制数的二进制逆序数。示例1输入173输...原创 2019-09-02 09:15:25 · 435 阅读 · 0 评论 -
HDOJ 2035 人见人爱A^B 九度教程第57题 快速幂模板题
题目链接Problem Description求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。Output对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。Sample In...原创 2019-09-09 16:44:07 · 174 阅读 · 0 评论 -
POJ 3734 Blocks 矩阵快速幂
题目链接DescriptionPanda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in...原创 2019-08-29 21:39:07 · 190 阅读 · 0 评论 -
POJ 3070 Fibonacci 矩阵快速幂模板
题目链接题目大意:求第n项的斐波那契数对10000求余的结果解题思路:矩阵快速幂模板题矩阵快速幂模板://用二维vector来表示矩阵typedef vector<int> vec;typedef vector<vec> mat;typedef long long ll;const int M = 10000;//计算矩阵相乘mat mul(mat ...原创 2019-08-29 19:42:27 · 200 阅读 · 0 评论 -
HDOJ 1019 Least Common Multiple 最小公倍数 LCM
Problem DescriptionThe least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 1...原创 2019-08-26 16:18:33 · 266 阅读 · 0 评论 -
AOJ 0005 GCD and LCM 最大公约数和最小公倍数入门
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.InputInput consists of several data sets. Each data set contains a and b separa...原创 2019-08-26 16:27:06 · 193 阅读 · 0 评论 -
POJ 1930 Dead Fraction 无限循环小数化分数 数论+枚举
题目链接DescriptionMike is frantically scrambling to finish his thesis at the last minute. He needs to assemble all his research notes into vaguely coherent form in the next 3 days. Unfortunately, he n...原创 2019-08-27 11:26:10 · 343 阅读 · 0 评论 -
AOJ 0009 Prime Number 素数筛法 模板题
Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number div...原创 2019-08-27 12:03:11 · 606 阅读 · 0 评论 -
POJ 3126 Prime Path 素数筛法+BFS STL中pair模板使用
DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a ...原创 2019-08-27 15:48:34 · 241 阅读 · 0 评论 -
a+b 大整数相加
题目描述实现一个加法器,使其能够输出a+b的值。输入描述:输入包括两个数a和b,其中a和b的位数不超过1000位。输出描述:可能有多组测试数据,对于每组数据,输出a+b的值。样例输入:2 610000000000000000000 10000000000000000000000000000000样例输出:810000000000010000000000000000000解题...原创 2019-06-29 18:11:56 · 1621 阅读 · 0 评论 -
质因数的个数 九度教程第54题 分解素因数
题目链接求正整数N(N>1)的质因数的个数。 相同的质因数需要重复计算。如120=2*2*2*3*5,共有5个质因数。输入描述:可能有多组测试数据,每组测试数据的输入是一个正整数N,(1<N<10^9)。输出描述:对于每组数据,输出N的质因数的个数。示例1输入120输出5题目大意:对输入的某个整数分解素因数,并计算出每个素因数所对应的幂指数。即对给定整...原创 2019-08-27 20:16:00 · 329 阅读 · 0 评论 -
POJ 3421 X-factor Chains 分解素因数+排列组合
题目链接DescriptionGiven a positive integer X, an X-factor chain of length m is a sequence of integers,1 = X0, X1, X2, …, Xm = XsatisfyingXi < Xi+1 and Xi | Xi+1 where a | b means a perfectly div...原创 2019-08-27 21:41:48 · 294 阅读 · 0 评论 -
POJ 3292 Semi-prime H-numbers 素数筛法变种
DescriptionThis problem is based on an exercise of David Hilbert, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that.An H-number is a positive num...原创 2019-08-28 11:06:51 · 197 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers 快速幂+判断素数 快速幂模板
题目链接DescriptionFermat’s theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (b...原创 2019-08-28 20:19:43 · 180 阅读 · 0 评论 -
POJ 1995 Raising Modulo Numbers 快速幂模板题
题目链接DescriptionPeople are different. Some secretly read magazines full of interesting girls’ pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult ma...原创 2019-08-28 21:13:08 · 174 阅读 · 0 评论 -
九度OJ1100 最短路径(需要使用高精度整数) 高精度整数+dijkstra算法
题目链接N个城市,标号从0到N-1,M条道路,第K条道路(K从0开始)的长度为2^K,求编号为0的城市到其他城市的最短距离输入描述:第一行两个正整数N(2<=N<=100)M(M<=500),表示有N个城市,M条道路接下来M行两个整数,表示相连的两个城市的编号输出描述:N-1行,表示0号城市到其他城市的最短路,如果无法到达,输出-1,数值太大的以MOD 100000...原创 2019-09-11 16:42:15 · 303 阅读 · 0 评论