
数学
小星星亮闪闪
游戏开发者
展开
-
质因数分解
(1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。 (2)如果n<>k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n, 重复执行第一步。 (3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。#include <cstdio>#include <iostream>int main(){ int n,i; printf("原创 2016-07-22 12:38:05 · 331 阅读 · 0 评论 -
Again Prime? No Time.
The problem statement is very easy. Given a number n you have to determine the largest power of m,not necessarily prime, that divides n!.InputThe input file consists of several test cases. The first转载 2016-07-22 17:10:12 · 292 阅读 · 0 评论 -
BFS
模板思路:这里利用了结构体队列来保存每一个情况下的坐标x和步数。然后从里面取出来判断,取出来后还要就这个点的坐标x再去对每一种情况来变化,变化后的每一种不重复的情况又保存进队列里面,依次重复上述步骤。然后当第一次==判断成立时,就是我们的最短的步数。就可以返回了。#include <iostream>#include <cstring>#include <cstdlib>#include <c原创 2016-07-26 13:29:19 · 282 阅读 · 0 评论 -
辗转相除法(最大公约数)
作为数学问题中的基本算法,它扮演者重要的角色。 简单的形式: int GCD(int a,int b) { if(b==0) return b; return GCD(b,a%b) } 还有一种分解的: int GCD(int a,int b) { int r;原创 2016-07-19 22:39:34 · 296 阅读 · 0 评论 -
Expect the Expected(dp+概率)
问题:Some mathematical background. This problem asks you to compute the expected value of a random variable. If you haven’t seen those before, the simple definitions are as follows. A random variable is原创 2016-07-21 16:08:15 · 687 阅读 · 0 评论 -
How do you add?(dp)
题目: Larry is very bad at math — he usually uses a calculator, which worked well throughout college. Unforunately, he is now struck in a deserted island with his good buddy Ryan after a snowboarding原创 2016-07-21 22:06:34 · 518 阅读 · 0 评论 -
dp对组合数的预处理和快速幂取模模板
代码部分: for(int i=0;i<=2000;i++){ dp[i][1]=i%1007;//C(n,1)=n; dp[i][0]=dp[i][i]=1;//C(n,0)=C(n,n)=1; } for(int i=2;i<=2000;i++){ for(int j=1;j<=i;j++){ dp[i原创 2016-07-20 16:21:05 · 1262 阅读 · 0 评论