题目1076:N的阶乘(大数乘法)
题目链接:http://ac.jobdu.com/problem.php?pid=1076
详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus
参考代码:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <cmath>
#define MAX_SIZE 10010
using namespace std; int n;
int pos[MAX_SIZE]; int main(){
while(~scanf("%d",&n)){
memset(pos,,sizeof(pos));
if(==n){
printf("1\n");
continue;
}
int i,j;
int length = ;
pos[]=;
for(i = ; i <= n ; i++){
int carry = ;
for(j = ; j < length ; j++){
pos[j] = pos[j] * i + carry;
if(pos[j]>=){
carry = pos[j]/;
pos[j] = pos[j]%;
}
else{
carry = ;
}
}
while(carry!=){
pos[length++] = carry % ;
carry/=;
}
}
for(i = MAX_SIZE ; i >= ; i--){
if(pos[i]!=)
break;
}
for(j = i ; j >= ; j--){
printf("%d",pos[j]);
}
printf("\n");
}
return ;
}
/**************************************************************
Problem: 1076
User: zpfbuaa
Language: C++
Result: Accepted
Time:1480 ms
Memory:1560 kb
****************************************************************/
题目1076:N的阶乘(大数乘法)的更多相关文章
- 51nod1057-N的阶乘(大数乘法巧解)
这道大数乘法开始我是想套板子模拟的..然后就发现2/3的例子都wa了.(惊了).然后在思考后发现n2的板子的确过不了这么多的大数.(不看题的下场).所以,我在网上发现了分块求大数的方法.%%% 思路来 ...
- 九度OJ 1076 N的阶乘 -- 大数运算
题目地址:http://ac.jobdu.com/problem.php?pid=1076 题目描述: 输入一个正整数N,输出N的阶乘. 输入: 正整数N(0<=N<=1000) 输出: ...
- 51nod 1027大数乘法
题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...
- 【九度OJ】题目1076:N的阶乘 解题报告
[九度OJ]题目1076:N的阶乘 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1076 题目描述: 输入一个正整数N,输 ...
- [POJ] #1001# Exponentiation : 大数乘法
一. 题目 Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 156373 Accepted: ...
- HDOJ-1042 N!(大数乘法)
http://acm.hdu.edu.cn/showproblem.php?pid=1042 题意清晰..简单明了开门见山的大数乘法.. 10000的阶乘有35000多位 数组有36000够了 # i ...
- 51 Nod 1027 大数乘法【Java大数乱搞】
1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B的长度 ...
- 51 Nod 1028 大数乘法 V2【Java大数乱搞】
1028 大数乘法 V2 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A ...
- PAT 1023 Have Fun with Numbers[大数乘法][一般]
1023 Have Fun with Numbers (20)(20 分) Notice that the number 123456789 is a 9-digit number consistin ...
随机推荐
- Linux环境安装PostgreSQL-10.1[转]
环境及资源 Linux版本:CentOS release 6.5 PostgresSQL版本:postgresql-10.1 PostgreSQL官网下载地址:https://www.postgres ...
- Ubuntu一般软件安装后的路径
Ubuntu一般安装的软件查找路径: computer/usr/local/
- u3d外部资源加载加密
原文地址:http://www.cnblogs.com/88999660/archive/2013/04/10/3011912.html 首先要鄙视下unity3d的文档编写人员极度不负责任,到发帖为 ...
- js document.activeElement及使用
// 解决键盘弹出后挡表单的问题 // 解决键盘弹出后挡表单的问题 window.addEventListener('resize', function() { if( document.active ...
- eclipse常用插件介绍
1. 测试覆盖率工具:EclEmma https://www.cnblogs.com/Ming8006/p/5811425.html 2. 单元测试系列:如何使用JUnit+JaCoCo+EclEmm ...
- spring原理机制
转自:http://blog.csdn.net/nrain2/article/details/45459311 1,关于spring容器: spring容器是Spring的核心,该 容器负责管理spr ...
- 通过expect免自动输入密码登陆远程服务器
通过expect免自动输入密码登陆远程服务器 1.前提必须已经安装expect 2.新建login.sh,文件内容如下 #!/usr/bin/expect -f spawn ssh root@140. ...
- 6 Django系列之关于models的sql语句日常用法总结
preface Django提供了强大的ORM,我们可以通过ORM快速的写出我们想要对数据做什么样操作的代码.下面就说说我在日常工作中的用法: 外键关联精确查询 应用场景:表A host字段关联到了表 ...
- andoid-sdk 安装时出现 Stopping ADB server failed(code -1) 错
出错原因: cmd在path路径找不到adb命令,是因为adb.exe文件存在于android-sdk安装目录platform-tools/子目录下,要将这个路径配置到环境变量里面. 解决方案: 按照 ...
- 用Fiddler查看 Android/iOS 网络请求
1.下载fiddler,尽量到官方网站找最新的版本 我这里也放了一个:http://files.cnblogs.com/xiaokang088/fiddler4setup.zip 2. 打开Fiddl ...