acm_数论
文章平均质量分 66
小七和小墨
http://blog.csdn.net/ccsu_cherish
http://blog.csdn.net/shahdza/article/details/6632538
展开
-
ccsu 1042 斐波那契II 矩阵快速幂
题目是求f(n)mod10000以后的斐波那契数,n的范围是0矩阵相乘求斐波那契: 在二分的函数那里要注意的几点就是:当(n-1)为偶数进行二分以后,要返回单位矩阵,(n-1)为奇数就范围[1,1,1,0];而为什么当此时的n为奇数的时候要进行一次矩阵相乘的运算呢?可以举个例子:二分(n-1)=7: 7->3->1 。当为1以后return到上一次的调用函数,此时进行矩原创 2013-07-13 11:21:17 · 586 阅读 · 0 评论 -
hdu1134 Game of Connections 卡特兰数(大数)
This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, ... , 2n - 1, 2n consecutively in clockwise order on the ground to form a circle, and then, to draw some straight原创 2013-12-29 16:06:53 · 699 阅读 · 0 评论 -
hdu1205 吃糖果 鸽巢原理
题解:此题鸽巢原理证明出自:http://blog.csdn.net/hnust_xiehonghao/article/details/8005832鸽巢原理1.把某种糖果看做隔板,如果某种糖果有n个,那么就有n+1块区域,至少需要n-1块其他种糖果才能使得所有隔板不挨在一块..也就是说能吃完这种糖果.至少需要其他种类糖果n-1块..(鸽巢原理)2.数量最多的糖原创 2013-12-07 18:17:59 · 691 阅读 · 0 评论 -
Codeforces Round #122 (Div. 2) B. Square
There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square原创 2013-11-10 20:41:23 · 641 阅读 · 0 评论 -
Codeforces Round #212 (Div. 2) A. Two Semiknights Meet /B. Petya and Staircases
A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the ri原创 2013-11-15 17:18:29 · 1334 阅读 · 0 评论 -
Uva 10006 Carmichael Numbers 快速幂
An important topic nowadays in computer science is cryptography. Some people even think that cryptography is the only important field in computer science, and that life would not matter at all without原创 2013-09-29 17:11:30 · 549 阅读 · 0 评论 -
CodeForces 333A Secrets
Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive原创 2013-08-18 09:57:44 · 1105 阅读 · 0 评论 -
CodeForces 334B Eight Point Sets
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct原创 2013-08-18 09:46:05 · 761 阅读 · 0 评论 -
CodeForces 334A Candy Bags
Gerald has n younger brothers and their number happens to be even. One day he bought n2 candy bags. One bag has one candy, one bag has two candies, one bag has three candies and so on. In fact, for原创 2013-08-18 09:37:35 · 1093 阅读 · 0 评论 -
hdu3501 Calculation 2 欧拉函数
Given a positive integer N, your task is to calculate the sum of the positive integers less than N which are not coprime to N. A is said to be coprime to B if A, B share no common positive divisors ex原创 2013-08-24 09:39:29 · 638 阅读 · 0 评论 -
ccsu 1079求解素数 筛选法
筛选法求素数当数据量比较大时候,判素数的方法是会超时的,我们将前面的那道例题改造一下,变成下面这个题目:桐桐的思考桐桐在学完了上节课的知识后,对信息学越发感兴趣了。桐桐是一个很善于思考的学生,她发现上节课中例题的n最大是40000,如果数据再大一些,比如n=106,那么判素数的算法能否在1秒内给出答案呢?桐桐用程序实际测试的时间超过了1秒,你能帮助可爱的桐桐解决这个难题吗?即:在1秒的转载 2013-07-13 21:57:26 · 1583 阅读 · 0 评论 -
hdu1398 Square Coins 母函数
People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1-credit coins, 4-cre原创 2013-12-25 15:50:22 · 613 阅读 · 0 评论