
数学
raptor.
事了拂衣去,深藏功与名。
展开
-
POJ 1811 Prime Test【大素数判定】【素因子分解】
把发过的博客简单的理了一遍,竟然有那么几个题目猛地一看还是没啥想法,很陌生的感觉,哎~菜的不行了。这个大素数的判定看了好几天了,一直没明白,到专题结束也没交这个题,到现在也是云里雾里,把这份代码当做一个模板吧。感觉写出Miller-rabin和pollard-rho这俩算法的都溜的很,在此我也不做什么多的复数,大佬们的解释很清晰,Prime Test基本思想,素数的判定需要用到原创 2017-11-26 22:02:02 · 2056 阅读 · 0 评论 -
HDU 1905 + POJ 1730 【快速幂】
Pseudoprime numbers Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remain原创 2017-11-19 17:32:40 · 1893 阅读 · 0 评论 -
hdu2588+3501【欧拉函数】
这俩题目都算是欧拉函数的应用极致了,直接上题目 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, ...原创 2017-11-16 22:18:33 · 1966 阅读 · 0 评论 -
UVA10692+636
The operator for exponentiation is differentfrom the addition, subtraction, multiplicationor division operators in the sensethat the default associativity for exponentiationgoes right to left instea原创 2017-11-12 19:16:12 · 1990 阅读 · 0 评论 -
UVA10548+10717
In early days the concept of money was not there, and people used to sell goods by exchanging othergoods. Assume that in a society there are two kinds of goods A and B. Buyer has to pay an amountequiv原创 2017-11-11 22:42:24 · 1821 阅读 · 0 评论 -
Uva10616+10820
前天晚上看到有人一发a了那个大家都wa的欧拉函数的题,半夜十一点多就有人在群里问为什么,竟然是phi[1]=0,并且有人说本来不就应该是0吗,我一直以为是1,我很迷,百度百科了一下,确实是1啊,在数论,对正整数n,欧拉函数是小于n的正整数中与n互质的数的数目(φ(1)=1)。欧拉函数百度百科,可能确实是judge的不同只选了两个题目,放个欧拉函数相关的,见题目详解When particip...原创 2017-11-09 21:46:52 · 1780 阅读 · 0 评论 -
Uva10162+Uva10539
Uva10162Give you a integer number N (1100). Please compute S=11+22+33+…+NNGive the last digit of S to meInputInput file consists of several N’s, each N a line. It is ended with N =原创 2017-10-30 22:07:11 · 1929 阅读 · 0 评论 -
hdu1576 A/B
在欧几里得算法(辗转相除)的基础上还有拓展欧几里得算法,大体的定意就是对于不完全为0的非负整数,a,b,gcd(a,b),必然存在整数对x,y使得gcd(a,b)=ax+by,在找题的时候发现vj上除去poj的题目还是可以提交的,第一个算法很好理解,对于拓展代码的理解不是很透彻,对于这个题目,x不能是负的,只需要+mod再%mid即可/*欧几里得算法*/int gcd(int a,...原创 2017-10-22 21:25:17 · 1917 阅读 · 0 评论 -
uva11417 poj1305
这数论好多“套路”,一个一个的让我不知所措,很迷!!!发题之前先了解了解欧拉函数,就是1-n中与n互质的数的个数(gcd(i,n)==1)欧拉函数介绍两种求解欧拉函数的代码见连接内。具体到题目之中。Given the value of N, you will have to find the value of G. The definition of G is given...原创 2017-10-26 22:49:32 · 1879 阅读 · 0 评论 -
UVA138+HDU2973【筛素数】【威尔逊定理】
这两天实在天冷了,比较适合宅起来敲俩代码,这俩个题目脑洞都比较大,之前没接触这个,先放上这俩,其余题目单发。Street Numbers :有个程序员每天都遛狗,这很程序员,他家住的街道上是一条直线,一次往左依次往右,发现两次遛狗门牌号的和是一样的,问他家的门牌思路:假设门牌是1-n,他家的是m,anemia根据等差数里求和公式,得出直接暴力一发,tle,修改了输入处处还是超时,直接复制粘贴超时输...原创 2017-11-19 21:52:17 · 2007 阅读 · 0 评论 -
HDU6222Little Boxes
Little BoxesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 86 Accepted Submission(s): 34Problem DescriptionLittle boxes on原创 2017-11-05 17:26:27 · 2180 阅读 · 0 评论 -
HDU4336 Card Collector 【容斥原理】【数学期望】
Card Collector In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in the famous novel Wate原创 2017-12-07 22:08:11 · 2240 阅读 · 0 评论 -
HDU1695 GCD 【欧拉函数】【容斥原理】
最近看了很多容斥原理的题目,跟离散上学的不大一样了,有时候根本想不到,有些题目看了题解都不懂,凡是牵扯到位运算的我感觉都不简单。。。题意:求x∈[1,b]和y∈[1,d]的区间内有多少组gcd(x,y)==k,其中(x,y)(y,x)算是一组思路:先做一个小变换,b,d都除以k,问题变为求x∈[1,b/k]和y∈[1,d/k]的区间内有多少组gcd(x,y)==1在此基础上,令b=b/k,d=d/...原创 2017-12-07 21:12:42 · 1942 阅读 · 0 评论 -
周中训练笔记+HDU5478Can you find it【快速幂】
去图书馆借书,找到数论那一架子,空了一大片了,看了半天没找到想找的,跳来跳去,找了两本组合数学先凑合着,不大沾边,等大佬们看完,找他们借一下吧。陷入大素数判定无法自拔ing即将断电,简写,下面这个题题意:给你一个c,k1,b1,k2求满足下面式子的a,b思路:这个题目我在网上看了几波解释,都是草草的一句只需要判断n-1和n=2时候就行了,没什么解释,这几天脑子不是很灵活,想了很久为原创 2017-11-23 22:43:23 · 1903 阅读 · 0 评论 -
HDU1134Game of Connections 【卡特兰数】
java水过~~~~~~~~~~~~~~~~~~~~~卡特兰数~~~~~~~~~~~~~~~~~~~~~公式:令h(0)=1,h(1)=1,catalan数满足递推式:h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (n>=2)另类递推式:h(n)=h(n-1)*(4*n-2)/(n+1);h(n)=原创 2017-12-03 22:06:48 · 2003 阅读 · 0 评论 -
HDU1205+POJ1306【排列组合】
组合数学这块因为刷的比较慢,有些题目step都是做过的,加上几道水题,不再发了,简单拿两道排列组合的代表性题目总结总结。吃糖果:典型的排列组合高中数学题一个典型题就是插空的排列组合,想让相同的不相邻,插空是首选。把最多的汤拔出来,形成max-1个空位,剩下的谈只要比这些空位多即可满足不相邻了即max-1<=sum-maxCombinations 计算C(n,m)阶乘超范围,做点小处理,用gc...原创 2017-12-03 21:46:21 · 1933 阅读 · 0 评论 -
POJ 1035 Spell checker 【字符串暴力查找】
Spell checker You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of al原创 2017-11-21 11:47:55 · 2039 阅读 · 0 评论 -
POJ 2689 Prime Distance 【大区间筛素数】
Prime Distance The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of y原创 2017-11-21 09:31:32 · 1941 阅读 · 0 评论 -
HDU2837 Calculation【指数循环节】
Calculation Assume that f(0) = 1 and 0^0=1. f(n) = (n%10)^f(n/10) for all n bigger than zero. Please calculate f(n)%m. (2 ≤ n , m ≤ 10^9, x^y means the y th power of x).InputThe fi原创 2017-11-20 18:48:38 · 2144 阅读 · 0 评论 -
Uva10791
宿舍一过十点就断电是个问题,真是应了一句话,断电除了能阻挡我们学习,什么也阻挡不了,摊手,—_—昨天晚上做的题目吃鸡6到飞起,我喜欢,其他没什么好说的,发个在刷专题的题目LCM(Least Common Multiple) of a set of integers is defined as the minimum number, which is a multiple of al...原创 2017-11-02 21:41:39 · 1825 阅读 · 0 评论 -
筛素数
/*哇,博客用了这么久,花了老长时间整理了下博客,才发现原来他有自带的代码格式(倒数第四个按钮。。。)因为之前为了比赛简单的看过些数论的题目,所以这次先看着数论,博客从最简单的开始。各大oj好像都停了,没法水几个题了,数论印象最深的就是筛素数这一块,突然想起来没具体发过,简单的提过,PrimeGap里用到过,总结一次吧。第一种筛法较慢一些,O(nlog(n)),具体就是没选出一个新素数...原创 2017-10-19 20:08:10 · 2077 阅读 · 0 评论 -
Prime Gap
Prime GapTime Limit : 10000/5000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 40 Accepted Submission(s) : 31Problem DescriptionThe sequence of n原创 2017-08-12 21:26:00 · 2072 阅读 · 0 评论 -
最小公倍数
最小公倍数Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5386 Accepted Submission(s): 3751 Problem Description给定两原创 2017-05-29 11:01:42 · 4638 阅读 · 0 评论 -
The 3n + 1 problem
The 3n + 1 problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1733 Accepted Submission(s): 744 Problem Descri原创 2017-06-18 15:11:16 · 1834 阅读 · 0 评论 -
Last non-zero Digit in N!
Last non-zero Digit in N!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1138 Accepted Submission(s): 463 Problem原创 2017-06-18 15:33:20 · 2145 阅读 · 0 评论 -
Big Number
Big NumberTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1220 Accepted Submission(s): 720 Problem Description原创 2017-06-18 15:36:08 · 1727 阅读 · 0 评论 -
A + B Problem II
A + B Problem IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3820 Accepted Submission(s): 1351 Problem Descrip原创 2017-06-19 09:11:36 · 1754 阅读 · 0 评论 -
How Many Trees?
How Many Trees?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1365 Accepted Submission(s): 722 Problem Descripti原创 2017-06-19 09:22:36 · 2049 阅读 · 0 评论 -
小兔的棋盘
小兔的棋盘Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1169 Accepted Submission(s): 721 Problem Description小兔的叔原创 2017-06-19 09:43:07 · 1831 阅读 · 0 评论 -
折线分割平面
折线分割平面Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 870 Accepted Submission(s): 658 Problem Description我们看到原创 2017-06-19 09:45:52 · 1840 阅读 · 0 评论 -
三角形
三角形Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 957 Accepted Submission(s): 710 Problem Description用N个三角形最原创 2017-06-18 15:06:35 · 2043 阅读 · 0 评论 -
Wolf and Rabbit
Wolf and RabbitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2997 Accepted Submission(s): 1652 Problem Descript原创 2017-06-18 15:03:28 · 1786 阅读 · 0 评论 -
Largest prime factor
Largest prime factorTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6700 Accepted Submission(s): 2047 Problem Des原创 2017-05-29 22:09:50 · 1756 阅读 · 0 评论 -
七夕节
七夕节Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6229 Accepted Submission(s): 2145 Problem Description七夕节那天原创 2017-05-29 22:18:09 · 1909 阅读 · 0 评论 -
The area
The areaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1850 Accepted Submission(s): 1449 Problem Description原创 2017-05-29 22:21:23 · 1764 阅读 · 0 评论 -
Leftmost Digit
Leftmost DigitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3718 Accepted Submission(s): 1645 Problem Descripti原创 2017-06-18 14:25:35 · 1799 阅读 · 0 评论 -
小数化分数2
小数化分数2Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3668 Accepted Submission(s): 1357 Problem DescriptionRa原创 2017-06-18 14:34:08 · 2213 阅读 · 0 评论 -
Fibonacci
FibonacciTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4437 Accepted Submission(s): 2002 Problem Description原创 2017-06-18 14:38:05 · 1773 阅读 · 0 评论 -
Joseph
JosephTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3001 Accepted Submission(s): 1694 Problem DescriptionTh原创 2017-06-18 14:49:36 · 1957 阅读 · 0 评论 -
汉诺塔VII
汉诺塔VIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1814 Accepted Submission(s): 1293 Problem Descriptionn个原创 2017-06-18 14:59:48 · 2607 阅读 · 0 评论