每日一九度之 题目1076:N的阶乘
时间限制: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的阶乘的更多相关文章
- 每日一九度之 题目1043:Day of Week
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7336 解决:2563 题目描述: We now use the Gregorian style of dating in Russia. ...
- 每日一九度之 题目1042:Coincidence
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3007 解决:1638 题目描述: Find a longest common subsequence of two strings. 输入 ...
- 每日一九度之 题目1041:Simple Sorting
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4883 解决:1860 题目描述: You are given an unsorted array of integer numbers. ...
- 每日一九度之 题目1040:Prime Number
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6732 解决:2738 题目描述: Output the k-th prime number. 输入: k≤10000 输出: The k- ...
- 每日一九度之 题目1038:Sum of Factorials
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2109 解决:901 题目描述: John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, ...
- 每日一九度之 题目1039:Zero-complexity Transposition
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3372 解决:1392 题目描述: You are given a sequence of integer numbers. Zero-co ...
- 每日一九度之 题目1033:继续xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5502 解决:1351 题目描述: 当n为3时,我们在验证xxx定律的过程中会得到一个序列,3,5,8,4,2,1,将3称为关键数, ...
- 每日一九度之 题目1031:xxx定律
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6870 解决:4302 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...
- 每日一九度之 题目1030:毕业bg
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2046 解决:894 题目描述: 每年毕业的季节都会有大量毕业生发起狂欢,好朋友们相约吃散伙饭,网络上称为“bg”.参加不同团体的b ...
随机推荐
- autorelease基本概念
// // main.m // 01-autorelease基本概念 // // Created by apple on 14-3-18. // Copyright (c) 2014年 app ...
- Java Collections的排序之二
package test.list; import java.util.ArrayList; import java.util.Collections; import java.util.HashSe ...
- 详细讲解Quartz.NET
Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用中.它提供了巨大的灵活性而不牺牲 ...
- linux:centos准备及安装
1>.安装前准备(将虚拟机和映像文件iso下载好) 1.1>.centos下载(建议使用Filezilla下载(http://filezilla-project.org/download. ...
- org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map
mybatis 出现这个错误是 参数类型写错了.parameterType 写成了parameterMap
- NSMutableDictionary中元素替换
NSMutableDictionary *dic = [NSMutableDictionary new]; [dic addEntriesFromDictionary:@{@"key&quo ...
- ViewController添加子控制器 并且弹出
/** * 初始化子控制器 */ - (void)setupChildVcs { for (int i = 0; i<6; i++) { UIViewController *vc = [[UI ...
- CCSprite的使用方法大全
一.精灵创建及初始化 1.从图片文件创建: CCSprite *sprite = [CCSprite spriteWithFile:@"ImageFileName.png"]; 默 ...
- windows下gvim与gcc的一键环境的搭建
此处略去在windows中配置gcc的方法.默认你已经能够在命令提示符下直接使用gcc了. 其实就是写了一个vimscript的.vim文件,然后在 _vimrc 中使用source命令引用进来. 以 ...
- sqlhelper-sql数据库
using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; usin ...