自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 Prime Distance(两次筛素)

Prime DistanceTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 15858 Accepted: 4213DescriptionThe branch of mathematics called number theory is about prope

2016-05-25 13:23:18 226

原创 素数筛选(筛选小于等于MAXN的素数)

/**素数筛选,存在小于等于MAXN的素数*prime[0]存的是素数的个数 */const int MAXN=1000010;int prime[MAXN+1];void getPrime(){ memset(prime,0,sizeof(prime)); for(int i=2;i<=MAXN;i++) { if(!prime[i])prime[++prime[0]]=

2016-05-25 12:32:10 473

原创 素数筛选(判断<MAXN的数是否是素数)

/*素数筛选,判断小于MAXN的数是否是素数。 *notprime是一张表,为false表示是素数,true表示非素数*/const int MAXN=1000010;bool notprime[MAXN];//值为false表示素数,值为true表示非素数void init(){ memset(notprime,false,sizeof(notprime)); notprime[0]=

2016-05-25 12:23:39 358

原创 Pseudoprime numbers

F - Pseudoprime numbersTime Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 3641Appoint description: System Crawler  (2016-05-20)

2016-05-22 22:44:49 338

原创 GCD & LCM Inverse(目前超时)

GCD & LCM InverseTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 13128 Accepted: 2424DescriptionGiven two positive integers a and b, we can easily calcu

2016-05-22 22:17:53 296

原创 欧拉函数

欧拉函数 定义:在数论,对正整数n,欧拉函数是小于等于n的数中与n互质的数的数目。 ϕ (n) =   1..n中与n互质的数的个数 如何求ϕ (n)? 素因子展开+容斥原理 令n = p1r1p2r2...pkrkϕ(n)=n*(1-1/p1)*(1-1/p2)*...*(1-1/pk)(为什么?)提示:欧拉函数是积性函数——若m,n互

2016-05-21 10:51:55 261

原创 快速模幂

对于 a^b mod k,怎么求解? 简单!!!,用暴力求出a^b不就解决了?要是数据很大呢?显然用暴力解决不了。。。 怎么简洁美观的解决这个问题?? 提示:a*b mod c = (a mod c )*b mod c  将b表示成二进制形式 b = bnbn-1…b1b0a^b mod k = a^(bnbn-1…b1b0) mod k= a^(b0*2^0)*a^(b1*2^1)*

2016-05-21 10:28:05 285

原创 埃氏筛法(筛选素数)

首先,将2到n范围内的所有整数记下来,其中最小的数字2为素数。在表中将2的倍数划去,表中剩下最小的数为3,不能被更小的整除,然后将3的倍数划去。如果表中剩下的最小数为m,m是素数,然后将表中所有m的倍数都划去。像这样反复的操作,就能依次枚举n以内的素数了。复杂度:nloglogn代码实现:#include#includeusing namespace

2016-05-21 09:52:48 3914

原创 Survive in the White Terror

Problem B: Survive in the White TerrorTime Limit: 1 Sec  Memory Limit: 128 MBSubmit: 127  Solved: 31[Submit][Status][Web Board]Description       In 1927~1949, the whole of China were e

2016-05-20 17:04:23 327

原创 steps

StepsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7913 Accepted: 3632DescriptionOne steps through integer points of the straight line. The length of a

2016-05-20 16:50:16 268

原创 连连看(BFS)

Problem J: 连连看Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 37  Solved: 13[Submit][Status][Web Board]Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连

2016-05-20 10:56:16 293

原创 N的二进制中1的个数

解法一:对于二进制数的操作,我们知道除以一个2,原来的位数将会减少一位,如果除的过程中有余数,那么就表示当前位置有一个1,否则为0。以10100010为例:第一次除以2时,商为1010001,余0。第二次除以2时,商为101000,余1。第三次除以2时,商为10100,余0。第四次除以2时,商为1010,余0。第五次除以2时,商为101,余0。第六次除以2时,商为1

2016-05-19 15:15:13 1777

原创 求N!的位数

N!的位数提示:整数K的位数(int)log10(N)+1N!=1*2*......*N整数N!的位数(int)log10(1*2*......*N)+1log10(1*2*......*N)=log10(1)+log10(2)+......+log10(N)简单代码实现:#include#includeusing namespace std;int

2016-05-19 14:08:55 281

原创 求组合数(c(m,n))

定义:从n个不同元素中取出m(m≤n)个元素的所有组合的个数,叫做从n个不同元素中取出m个元素的组合数。用符号c(n,m) 表示。性质:c(n,m)=c(n,n-m);  c(n,0)=1;递推公式:c(n,m)=c(n-1,m-1)+c(n-1,m)C(n+1,m)=c(n,m-1)+c(n,m)=c(n,m-1)+c(n-1,m)+c(n-1,m-1);

2016-05-19 13:33:44 12174 2

原创 救公主(BFS)

Problem D: 救公主续Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 48  Solved: 19[Submit][Status][Web Board]Description公主又被魔王抓去了!公主被关在一个矩形迷宫里,有的位置有守卫把守。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深

2016-05-19 12:19:09 598

原创 无限循环小数化分数

Problem I: Dead FractionTime Limit: 1 Sec  Memory Limit: 128 MBSubmit: 54  Solved: 8[Submit][Status][Web Board]DescriptionMike is frantically scrambling to finish his thesis at the last

2016-05-18 15:27:56 466

原创 质数环

HDOJ1016 Prime Ring Problem(DFS第二层理解)Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in

2016-05-15 12:06:07 433

原创 Square

DescriptionProblem C: SquareGiven a set of sticks of various lengths, is it possible to join them end-to-end to form a square?Input The first line of input contains N, the number of te

2016-05-15 00:20:00 448

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除