
数论
文章平均质量分 79
kalilili
双眼闭三年。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
XTUOJ ABK(求出A和B的第K大公约数)
Accepted : 21 Submit : 171 Time Limit : 1000 MS Memory Limit : 65536 KB 题目描述 ABK是一个比A+B还要简单的题目,给出两个整数A,B,求出A和B的第K大公约数。 输入 第一行是一个整数N(N ≤ 10000),表示样例的个数。 以后每行一个样例,为3个整数A,B,K (1≤A原创 2015-01-12 12:56:24 · 1920 阅读 · 1 评论 -
UVA 11029 Leading and Trailing(大数n^k的前x位高精度问题)(好题)
Problem C Leading and Trailing Time limit: 2 seconds Apart from the novice programmers, all others know that you can’t exactly represent numbers raised to some high power.原创 2015-04-12 10:54:25 · 1132 阅读 · 0 评论 -
LightOJ 1236 Pairs Forming LCM(唯一分解定理)
大致题意:求the number of pairs (i, j) for which lcm(i, j) = n and (i ≤ j ). 数据范围: T (≤ 200)denoting the number of test cases. Each case starts with a line containing an integer n (1 ≤ n ≤ 1014).原创 2015-04-12 11:06:52 · 1464 阅读 · 0 评论 -
Light OJ 1138 Trailing Zeroes (III)(n!中素数p的幂问题)
题意:求n,满足n!的末尾有Q个0 数据范围:T (≤ 10000), denoting the number of test cases. Each case contains an integer Q (1 ≤ Q ≤ 108) in a line. 思路:n!中素数p的幂公式: [n/p]+[n/p^2]+[n/p^3]+…… 证明在http://www.cnblogs.原创 2015-04-12 11:24:50 · 877 阅读 · 0 评论 -
HDU 1573 X问题(一元线性同余方程组)
X问题 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3850 Accepted Submission(s): 1228 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod原创 2015-04-07 11:12:01 · 956 阅读 · 0 评论 -
POJ 1006 生理周期(中国剩余定理)
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 118302 Accepted: 37136 Description 人生来就有三个生理周期,分别为体力、感情和智力周期,它们的周期长度为23天、28天和33天。每一个周期中有一天是高峰。在高峰这天,人会在相原创 2015-04-08 11:05:33 · 653 阅读 · 0 评论 -
UVA11582 Colossal Fibonacci Numbers!(fibonacci序列模x的周期性)
题意:两个非负整数a,b 思路:显然a^b只能用快速幂,而且还必须要取模,所以去尝试找f(n)mod x的周期 不能发现当二元组(f[i]%x,fp[i-1]%x)=(f[0]%x,f[1]%x) 的时候开始循环,所以周期为i 因为f[n]%x的余数最多只有1000种所以在f[0...n^2]以内就能找到周期 // Accepted C++ 0.096 #include #inclu原创 2015-04-13 22:49:23 · 874 阅读 · 0 评论 -
Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess(DP+组合数取模)(好题)
C. Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Giant chess is quite common in Ge原创 2015-07-23 21:55:05 · 739 阅读 · 0 评论 -
URAL 1907. Coffee and Buns(数论推导+容斥原理)
1907. Coffee and Buns Time limit: 1.0 second Memory limit: 64 MB Planet Ataraxia is known for its education centers. The people who are expected to take high social positions in future are原创 2015-08-05 23:33:28 · 821 阅读 · 0 评论 -
HDU 5430 Reflect (欧拉函数) (类似UVA 12493 Stars)
问题描述 从镜面材质的圆上一点发出一道光线反射NN次后首次回到起点。 问本质不同的发射的方案数。 输入描述 第一行一个整数T,表示数据组数。T \leq 10T≤10 对于每一个组,共一行,包含一个整数,表示正整数N(1 \leq N \leq 10^{6})N(1≤N≤106)。 输出描述 对于每一个组,输出共一行,包含一个整数,表示答案。 输入样例 1 4原创 2015-09-08 11:20:17 · 527 阅读 · 0 评论 -
51nod 1130 N的阶乘的长度(阶乘近似公式--斯特林公式)
大致题意: 求n!有多少位,n 大致思路: 显然是企图求 lg(n!)+1 向下取整 显然求lg(n!) 展开的复杂度是On的 但是,他是求多少位,有n!的近似公式斯特林公式(Stirling's approximation) 显然对于求对数函数来说精确度在n比较大的情况下必然满足。 //#pragma comment(link原创 2015-09-03 19:24:43 · 1352 阅读 · 0 评论 -
Light OJ Aladdin and the Flying Carpet(约数个数)
Input Input starts with an integer T (≤ 4000), denoting the number of test cases. Each case starts with a line containing two integers: ab(1 ≤ b ≤ a ≤ 1012) where a denotes the area of the carp原创 2015-04-12 10:30:03 · 682 阅读 · 0 评论 -
POJ 2115-C Looooops(基础一元线性同余方程)
题意: 对于C的for(i=A ; i!=B ;i +=C)循环语句,问在k位存储系统中循环几次才会结束。 若在有限次内结束,则输出循环次数。 否则输出FOREVER 思路: 易列出同余方程: x*C+y*2^k = B-A用拓展gcd求解即可 //148K 0MS C++ 808B #include #include #include #includ原创 2015-04-07 00:34:46 · 1447 阅读 · 0 评论 -
HDU 4923 Room and Moor(数学+YY)(好题)
题意: 给定一个长度为n的,由0和1组成的序列ai,求一个序列bi,使得∑(bi-ai)^2最小。其中0 思路:显然开头为0的的部分和结尾为1的部分不用考虑 然后把其他序列划分成多个11111000形式的区域(这步也需要YY),每个区域分别求出bi(因地制宜的YY2333),求bi是二次函数的对称轴,如果bi不满足递增要求,比如bi-1>bi,所以如果不改变bi-1,bi至少要增原创 2015-03-21 10:55:04 · 738 阅读 · 0 评论 -
NEFU 120 梅森素数(梅森数素数判定--Lucas-Lehmer测试判定)
梅森素数 Problem : 120 Time Limit : 1000ms Memory Limit : 65536K description 由于梅森学识渊博,才华横溢,为人热情以及最早系统而深入地研究2p-1 型的数(其中p为素数),为了纪念他,数学界就把这种数称为“梅森原创 2015-04-03 17:31:10 · 2338 阅读 · 0 评论 -
NEFU 117 素数个数的位数 (素数定理)
素数个数的位数 Problem : 117 Time Limit : 1000ms Memory Limit : 65536K description 小明是一个聪明的孩子,对数论有着很浓烈的兴趣。他发现求1到正整数10n 之间有多少个素数是一个很难的问题,该问题的难以决定于n原创 2015-04-02 17:51:38 · 803 阅读 · 0 评论 -
NEFU 118 n!后面有多少个0 (n!的素因子幂问题)
n!后面有多少个0 Problem : 118 Time Limit : 1000ms Memory Limit : 65536K description 从输入中读取一个数n,求出n!中末尾0的个数。 input 输入有若干行。第一行上原创 2015-04-03 10:50:18 · 905 阅读 · 0 评论 -
NEFU 119 组合素数 (n!素因数p的幂的求法)
组合素数 Problem : 119 Time Limit : 1000ms Memory Limit : 65536K description 小明的爸爸从外面旅游回来给她带来了一个礼物,小明高兴地跑回自己的房间,拆开一看是一个很大棋盘(非常大),小明有所失望。不过没过几天发原创 2015-04-03 11:31:42 · 860 阅读 · 0 评论 -
POJ 2689 Prime Distance(素数区间筛法--经典题)
大致题意:给定[L,R]区间,找出区间内的每个素数 数据范围 : 1 R-L 1,000,000. R的数值太大,所以不能直接筛[0,R]的,要空间和时间优化,用到区间筛法,另外注意不能用int,因为R和L都是满int的,中间有很多细节处理会爆int的,还要注意1不是素数,所以在区间筛中要特判一下,是个易错的地方 //1160K 16MS C++ 1539B #include #in原创 2015-04-03 23:26:14 · 2615 阅读 · 0 评论 -
POJ 1061 青蛙的约会(初遇扩展gcd--解最小正整数解)
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 94253 Accepted: 17425 Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到原创 2015-04-01 21:16:34 · 763 阅读 · 0 评论 -
HDU 2669 Romantic(扩展欧几里德)
题意:Now tell you two nonnegative integer a and b. Find the nonnegative integer X and integer Y to satisfy X*a + Y*b = 1. 而且要满足X是通解中最小的。 注意X可以取0就可以了 //31MS 1808K 761 B G++ #include #include #include原创 2015-04-01 23:02:12 · 541 阅读 · 0 评论 -
关于数的一些算法
1.寻找一个数的所有质因数 2.寻找一个数n的所有约数 3.寻找a,b两个整数的所有公约数 等...原创 2015-01-05 16:20:04 · 1082 阅读 · 3 评论 -
POJ 2891 Strange Way to Express Integers(一元线性同余方程组模版题)
题意:给出n个模方程组:x mod ai = ri。求x的最小正值。如果不存在这样的x,那么输出-1. 涉及的数论知识: 对于一般式ax ≡ b(mod m) 当a=1时,两个同余方程就可以合并成一个同余方程 比如对于本题: x mod a1=r1 x mod a2=r2 有不定方程: x=r2+a2*y2 x=r2+a2*y2 联立: a1y1+原创 2015-04-06 22:53:20 · 1019 阅读 · 0 评论 -
UVA 12493 Stars (欧拉函数--求1~n与n互质的个数)
https://uva.onlinejudge.org/index.phpoption=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3937 题目:http://acm.bnu.edu.cn/v3/external/124/12493.pdf 大致题意:圆上有偶数n个点,每间隔m个点连起来,最后可以把所原创 2015-08-15 00:19:02 · 1417 阅读 · 0 评论