码迷,mamicode.com
首页 >  
搜索关键字:阶乘    ( 1901个结果
10000内数阶乘
#include#include#include#includeusing namespace std;#define D 10000clock_t stop,start;int main(){ int i,j,c,p,n; while(cin>>n){ start=clock(); vecto.....
分类:其他好文   时间:2015-03-13 23:44:29    阅读次数:176
南阳oj-大数阶乘
这题不会,水平太次,把问题转换为程序的能力太弱了,不知道哪方面不足。直接copy的最优代码: #include#includeusing namespace std;//存储20000以内的阶乘int a[15470]; //用数组来存储结果,每个元素存一个五位数int main(){ ...
分类:其他好文   时间:2015-03-11 21:18:35    阅读次数:183
hdu 1141 Factstone Benchmark 数论水题,,阶乘用斯特林公式
Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, continuing its strategy of doubling the word-size every ten years. (Amtel released a 64-bit computer in 2000, a 32-bit comp...
分类:其他好文   时间:2015-03-11 17:24:45    阅读次数:189
高精阶乘
求n!。当n很大的时候,会超出整数的范围。这里用数组来进行高精阶乘。a[1]是个位,a[2]是十位......依次类推。每次要乘一个数的时候,就从个位(即a[1])开始乘这个数,>10的时候要%10再进位。 1 #include 2 #include 3 const int N=100000; 4 ...
分类:其他好文   时间:2015-03-10 22:47:50    阅读次数:130
JavaScript高级程序设计:第七章 - 函数
六、函数表达式 //把函数当成值来使用的情况下,都可以使用匿名函数递归//递归函数是在一个函数通过名字调用自身的情况下构成的//使用函数声明来定义递归函数可能会出现问题//这是一个经典的递归阶乘函数function factorial(num) { if (num<1){ return 1...
分类:编程语言   时间:2015-03-09 09:19:07    阅读次数:187
Factorial Trailing Zeroes
这道题本质上是求阶乘中5的个数。还有一个公式即:[n/k]代表1~n中能被k整除的个数。class Solution{public: int trailingZeroes(int n) { int num= 0; while(n>0) { n...
分类:其他好文   时间:2015-03-08 14:07:24    阅读次数:107
#295(div.2)E.Pluses everywhere
1.题目描述:点击打开链接 2.解题思路:本题是一道组合数学题,一开始用递归的思想做,但结果错误。学习了别人的解法后,豁然开朗。正确的解法是关注每一位数对整体的贡献值。比如输入的n位数是D1D2D3...D(n-1)D(n),那么当D(i)作为个位数时,它的前面必然有一个‘+’。剩下的k-1个‘+’被安置在剩下的n-2个空隙中,因此一共有C(n-2,k-1)种情况,D(i)的总贡献值是D(i)*...
分类:其他好文   时间:2015-03-07 08:33:50    阅读次数:138
Factorial Trailing Zeroes
求一个整数n的阶乘后面有几个0 思路:0肯定是由5*2=10得到,2的个数肯定远大于5,所以只要数一下n的阶乘的因式分解里有几个5即可。 class Solution {public: int trailingZeroes(int n) { int count = 0; while (n) { co...
分类:其他好文   时间:2015-03-05 22:18:51    阅读次数:132
SPOJ Problem 11:Factoral
这是一道水题,求某数阶乘结尾0的个数。啥都不说了,上代码#includeint n,x,y;int main(){ for (scanf("%d",&n);n--;){ for (scanf("%d",&x),y=0;x;x/=5)y+=x/5; printf("%...
分类:其他好文   时间:2015-03-03 20:32:15    阅读次数:120
SPOJ Problem 24:Small factorials
求阶乘,注意数据范围,要用高精。#include#includeint a[300];int n,x,y,l,i,j;int main(){ for (scanf("%d",&n);n--;){ scanf("%d",&x); memset(a,0,sizeof(a...
分类:其他好文   时间:2015-03-03 20:26:59    阅读次数:127
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!