51nod 1057 N的阶乘 (大数运算)
输入N(1 <= N <= 10000)
输出N的阶乘
5
120 压位: 每个数组元素存多位数字
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
#define pi 3.1415926
#define e 2.718281828459
#define ll long long
const int mod=1e8;
const int N=;
int main()
{
int n,i,j,m;
ll a[N]={},c;
scanf("%d",&n);
m=;
for(i=;i<=n;i++){
c=;
for(j=;j<=m;j++){
a[j]=a[j]*i+c;
c=a[j]/mod;
a[j]%=mod;
}
if(c>){
m++;
a[m]=c;
}
}
printf("%lld",a[m]);
for(i=m-;i>=;i--)
printf("%08lld",a[i]);
printf("\n");
return ;
}
51nod 1057 N的阶乘 (大数运算)的更多相关文章
- 51NOD 1057 N的阶乘
1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入N求N的阶乘的准确值. Input 输入N(1 <= N <= 10000) ...
- 51nod 1057 n的阶乘 (压位优化)
题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1057&judgeId=605203 使用压位进行优化, ...
- 九度OJ 1076 N的阶乘 -- 大数运算
题目地址:http://ac.jobdu.com/problem.php?pid=1076 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: ...
- (进制)51NOD 1057 N的阶乘
输入N求N的阶乘的准确值. Input 输入N(1 <= N <= 10000) Output 输出N的阶乘 Input示例 5 Output示例 120解:这其实是MOD进制,将一个 ...
- 1057 N的阶乘(大数运算)
题目链接:51nod 1057 N的阶乘 #include<cstdio> using namespace std; typedef long long ll; ; const int m ...
- 51 Nod 1057 N的阶乘【Java大数乱搞】
1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入N求N的阶乘的准确值. Input 输入N(1 <= N <= 10000) Ou ...
- 收藏的一段关于java大数运算的代码
收藏的一段关于java大数运算的代码: package study_02.number; import java.math.BigDecimal; import java.math.BigIntege ...
- 大数运算(python2)
偶然又遇到了一道大数题,据说python大数运算好屌,试了一发,果然方便-1 a = int( raw_input() ); //注意这里是按行读入的,即每行只读一个数 b = int( raw_in ...
- 1057 N的阶乘
1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 输入N求N的阶乘的准确值. Input 输入N(1 <= N <= 10000) Output 输出N的阶乘 Inp ...
随机推荐
- 使用shell脚本监控用户登陆服务器并发送提示信息给微信
1.需要在/etc/ssh/目录下面创建一个名为sshrc的文件,执行权限可给可不给,那么在有人通过ssh远程登录这台服务器的时候,这段脚本就会被执行 #!/bin/bash ###V1---### ...
- UniConnectDialog使用
对话框中文显示 设计视图 设置参数 取值结果 获取根据参数设置的值关键代码 UniConnection1.ConnectDialog := UniConnectDialog1; UniConnecti ...
- iot平台在k8s搭建过程
统一在 cd /opt/iot nohup /opt/iopservices.sh >/var/log/helmapi.log & 直接查看pod日志? kubectl logs i ...
- SecureCRT乱码问题的解决
== 安装后默认的设置是utf8,不是汉字乱码,是一块一块的看不清,OMG... 设置这两个页面就好了
- [LeetCode] 78. Subsets tag: backtracking
Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solut ...
- [LeetCode] 506. Relative Ranks_Easy tag: Sort
Given scores of N athletes, find their relative ranks and the people with the top three highest scor ...
- [LeetCode] 884. Uncommon Words from Two Sentences_Easy tag: Hash Table
We are given two sentences A and B. (A sentence is a string of space separated words. Each word co ...
- 命令行方式调用winrar对文件夹进行zip压缩示例代码
调用winRAR进行压缩 using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...
- python math random
很有用个的工具 值得好好看看,这是作者(python发明者)对于工作中使用到的大多数场景的提炼 //test.py 1 import math 2 3 print abs(-10) 4 print m ...
- jmeter压测之 监控--nmon
压测方法整理: 1. 写jmx脚本,整理csv数据文件: 2. 部署测试环境,把jmx和csv放在压测机,把监控脚本nmon放被压测机: 3. 安装nmon: a. w ...