10 2018 档案

摘要:费马定理的逆定理几乎可以用来判断一个数是否为素数,但是有一些数是判断不出来的,因此,Miller_Rabin测试方法对费马的测试过程做了改进,克服其存在的问题。 推理过程如下(摘自维基百科): 摘自另一篇博文(手动滑稽): 原理明白了,就直接上代码了(KuangBin大神的板子): 代码思路是, M 阅读全文
posted @ 2018-10-25 22:40 Daybreaking 阅读(319) 评论(0) 推荐(0)
摘要:线性筛的思想:每个被筛的数是通过它最小的质因子所筛去的。 这种思想保证了每个数只会被筛一次,从而达到线性。并且,这个思想实现起来非常巧妙(见代码注释)! 因为线性筛的操作中用到了倍数的关系去实现,因此欧拉函数可以顺便也计算出来,根据完全积性函数的性质还有数学推算,直接一条语句就算出来了。 1 #in 阅读全文
posted @ 2018-10-21 21:04 Daybreaking 阅读(260) 评论(0) 推荐(0)
摘要:Description Let's call the following process a transformation of a sequence of length nn . If the sequence is empty, the process ends. Otherwise, appe 阅读全文
posted @ 2018-10-07 22:07 Daybreaking 阅读(391) 评论(0) 推荐(0)
摘要:Description Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subjec 阅读全文
posted @ 2018-10-07 21:01 Daybreaking 阅读(567) 评论(0) 推荐(0)
摘要:Description Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sle 阅读全文
posted @ 2018-10-07 20:50 Daybreaking 阅读(272) 评论(0) 推荐(0)
摘要:母函数,又称生成函数。 母函数就是一列用来展示一串数字的挂衣架。 ——赫伯特·唯尔夫 。 母函数问题一般是,对于一个问题,抽象出一个生成函数。 以换硬币问题为例,有一元的,四元的,九元的........硬币无数个,问y元钱有几种组合方式。 设一个数的指数为y(组成y元钱),系数为有几种组合方式,开始 阅读全文
posted @ 2018-10-06 10:45 Daybreaking 阅读(203) 评论(0) 推荐(0)
摘要:On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows 阅读全文
posted @ 2018-10-06 10:08 Daybreaking 阅读(280) 评论(0) 推荐(0)
摘要:To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the optimal temperature for brewing the 阅读全文
posted @ 2018-10-06 09:42 Daybreaking 阅读(258) 评论(0) 推荐(0)
摘要:Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: 阅读全文
posted @ 2018-10-05 11:22 Daybreaking 阅读(337) 评论(0) 推荐(0)
摘要:You are given a ternary string (it is a string which consists only of characters '0', '1' and '2'). You can swap any two adjacent (consecutive) charac 阅读全文
posted @ 2018-10-04 11:25 Daybreaking 阅读(278) 评论(0) 推荐(0)
摘要:You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become 阅读全文
posted @ 2018-10-04 09:30 Daybreaking 阅读(242) 评论(0) 推荐(0)
摘要:Berland shop sells nn kinds of juices. Each juice has its price cici. Each juice includes some set of vitamins in it. There are three types of vitamin 阅读全文
posted @ 2018-10-03 17:36 Daybreaking 阅读(360) 评论(0) 推荐(0)