
-> 数论 <-
文章平均质量分 64
Joefery
生命不息,战斗不止。
展开
-
N!的位数两种方法求解
第一种方法:将n!表示成10的次幂,即n!=10^M 则不小于M的最小整数就是 n!的位数,对该式两边取对数,有 M =log10^n!即: M = log10^1+log10^2+log10^3...+log10^n 循环求和,就能算得M值,该M是n!的精确位数#include#include#include#includeusing namespace std;原创 2016-05-29 20:45:43 · 1227 阅读 · 0 评论 -
Gym 101138I Prime Moving【素数测试】
Descriptionstandard input/outputStatementsThe author of this problem hopes that you already know the pig called Benny.Recently she started learning numbers. The first type of numbers she h原创 2016-10-28 11:15:08 · 434 阅读 · 0 评论 -
UVALive 7340 Sum of MSLCM【数学】
题目链接/* 题意:给定一个N,求从2~N的最小公倍数的和 类型:数学 分析:两种姿势可以A题,但是用时相差很大 1.用类似埃氏筛选法,处理出前缀和4000+ms 2.用类似因式分解的方法,分成两部分,sqrt(N)前和后,后的可以用求和公式,前的 用n/i*i求出来20ms*///第一种方原创 2016-10-26 01:35:35 · 1075 阅读 · 1 评论 -
POJ 1006 Biorhythms【中国剩余定理】
DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and the原创 2016-10-25 14:21:14 · 388 阅读 · 0 评论 -
POJ 2891 Strange Way to Express Integers【模线性方程组】(中国剩余定理非互质套用)
DescriptionElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following:Choose k different positive inte原创 2016-10-25 14:47:47 · 473 阅读 · 0 评论 -
中国剩余定理模版【中国剩余定理】
/* 问题:求解 n个方程:x=a[i](mod m[i]) (0<=i<n) 的x 类型:中国剩余定理 吐槽:这个模版要求m[i]之间两两互质啊QAQ*/#include#include#includeusing namespace std;typedef long long LL;const int maxn = 105;void ex_gcd(LL原创 2016-10-25 14:01:15 · 455 阅读 · 0 评论 -
与公约数有关的问题
第一道题是2015年浙江理工12月比赛的一道题4216: Jug HardDescriptionYou have two empty jugs and tap that may be used to fill a jug. When filling a jug from the tap, you can only fill it completely (i.e.,原创 2015-12-23 17:16:32 · 494 阅读 · 0 评论 -
codeforces #630 F. Selection of Personnel
题目链接排列组合 计算 C(N,5)+C(N,6)+C(N,7)#include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i,j,s=1; if(n-r<r)r=n-r; for(i=0,j=1;i<r原创 2016-07-13 13:16:33 · 559 阅读 · 0 评论 -
codefoces #630 G. Challenge Pennants
题目链接#include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i,j,s=1; if(r>n)return 0; if(n-r<r)r=n-r; for(i=0,j=1;i<r;i++){原创 2016-07-13 15:28:55 · 466 阅读 · 0 评论 -
codeforces 630H. Benches
题目链接一座城市有n条南北走向的街道和n条东西走向的街道,现要将5条不用的长凳放置在街道相交处,且同一条街道上的长凳数不超过一条,问有多少种放置方案 #include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i原创 2016-07-13 18:54:53 · 474 阅读 · 0 评论 -
codeforces #630 I. Parking Lot
题目链接4种不同的汽车,有2n-2个停车位,要求恰有n辆相同的车排在一起,问有多少种停车方案 分类讨论:1)n辆车在停车场两端,方案数为2*4*3*4^(n-3),2)n辆车不在两端,方案为4*(n-3)3*3*4^(n-4),所以总的停车方案有 24*4^(n-3)+36(n-3)*4^(n-4) #include原创 2016-07-13 20:09:57 · 442 阅读 · 0 评论 -
LightOj 1045 N!位数的应用
Digits of FactorialTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluDescriptionFactorial of an integer is defined by the following functionf(0) = 1f(n) = f(n -原创 2016-05-29 21:41:27 · 544 阅读 · 0 评论 -
Gym 101138C Stickmen【枚举+排列组合】
Descriptionstandard input/outputStatementsLimak is a little bear who loves to play with graphs. Recently, he defined a new structure in a graph and called it a stickman.A stickman is a set原创 2016-10-28 11:52:06 · 788 阅读 · 0 评论