时间限制:3 秒

内存限制:128 兆

特殊判题:

提交:7601

解决:2749

题目描述:

输入一个正整数N,输出N的阶乘。

输入:

正整数N(0<=N<=1000)

输出:

输入可能包括多组数据,对于每一组输入数据,输出N的阶乘

样例输入:
4
5
15
样例输出:
24
120
1307674368000

大数的乘法。

//Asimple
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <limits.h>
#define INF 0x7fffffff
using namespace std;
const int maxn = ;
typedef long long ll;
int n;
ll a[maxn]; int main(){
while( ~scanf("%d",&n) ){
if( n == ){
printf("1\n");
continue;
}
//进位
int c = , len = ;
memset(a,,sizeof(a));
a[] = ;
for(int i=; i<=n; i++){
c = ;
for(int j=; j<len; j++){
a[j] = a[j] * i + c;
if( a[j]>= ){
c = a[j] / ;
a[j] = a[j] % ;
} else c = ;
}
while( c != ){
int t = c % ;
a[len++] = t;
c = c / ;
}
}
int i, j;
for(i=maxn; i>=; i--){
if( a[i] != ){
break;
}
}
for(j=i; j>=; j--){
printf("%d",a[j]);
}
printf("\n");
}
return ;
}

每日一九度之 题目1076:N的阶乘的更多相关文章

  1. 每日一九度之 题目1043:Day of Week

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...

  2. 每日一九度之 题目1042:Coincidence

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...

  3. 每日一九度之 题目1041:Simple Sorting

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4883 解决:1860 题目描述: You are given an unsorted array of integer numbers. ...

  4. 每日一九度之 题目1040:Prime Number

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...

  5. 每日一九度之 题目1038:Sum of Factorials

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2109 解决:901 题目描述: John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, ...

  6. 每日一九度之 题目1039:Zero-complexity Transposition

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...

  7. 每日一九度之 题目1033:继续xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述:     当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...

  8. 每日一九度之 题目1031:xxx定律

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...

  9. 每日一九度之 题目1030:毕业bg

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2046 解决:894 题目描述:     每年毕业的季节都会有大量毕业生发起狂欢,好朋友们相约吃散伙饭,网络上称为“bg”.参加不同团体的b ...

随机推荐

  1. UICollection 重排 和汉字拼音

    http://nshint.io/blog/2015/07/16/uicollectionviews-now-have-easy-reordering/ NSMutableString *str = ...

  2. django apache 通过wsgi部署

    生产上部署django 1. 修改settings关闭debug DEBUG = False ALLOWED_HOSTS = ['*'] 2. 安装wsgi yum -y install mod_ws ...

  3. python password输入

    1.linux下用getpass,没有星号提示,符合linux风格 from getpass import getpasspwd = getpass('Enter the password: ') 2 ...

  4. "数学口袋精灵"bug的发现及单元测试

    1.项目内容: 团队项目:二次开发 至此,我们有了初步的与人合作经验,接下来投入到更大的团队中去. 也具备了一定的个人能力,能将自己的代码进行测试.接下来尝试在别人已有的基础上进行开发. 上一界51冯 ...

  5. java项目中可能会使用到的jar包解释

    一.Struts2 用的版本是struts2.3.1.1 一个简单的Struts项目所需的jar包有如下8个 1. struts2-core-2.3.1.1.jar: Struts2的核心类库. 2. ...

  6. fackbook的Fresco (FaceBook推出的Android图片加载库-Fresco)

    [Android开发经验]FaceBook推出的Android图片加载库-Fresco   欢迎关注ndroid-tech-frontier开源项目,定期翻译国外Android优质的技术.开源库.软件 ...

  7. paper 59:招聘

     借Valse宝地发条招聘广告:D[腾讯优图]技术大咖招聘 欢迎各位技术大咖尤其应届优秀毕业生投递简历.简历投递:youtu@tencent.com简历投递,邮件标题请按照以下格式:[腾讯_上海_招聘 ...

  8. Bootstrap布局设计

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  9. js 获取select 中option 的个数

    //document.writeln(document.getElementById("sel").options.length); //document.writeln(docu ...

  10. win7 IIS发布项目遇到的问题

     问题一: HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. 1.依次打开控制面板 ...