http://acm.hdu.edu.cn/showproblem.php?pid=1042

题意清晰..简单明了开门见山的大数乘法..

10000的阶乘有35000多位 数组有36000够了

# include <stdio.h>
# include <string.h>
# define MAX 36000 int BigNum[MAX], NowLen; void Multi(int number)
{
int Temp[MAX]={0}, Tlen = 0, t;//Temp保存乘后结果 while(number > 0)
{
t = number % 10;//依次取当前乘数的低位
number /= 10; for(int i = 0, j = Tlen; i <= NowLen; i++)//模拟乘法 先不管进位
{
Temp[j++] += BigNum[i] * t;
}
Tlen++;//每乘完一位 Temp的开始读入位置+1
} for(int i = 0; i < MAX; i++)//处理进位 接收结果
{
if(Temp[i] > 9)
{
Temp[i + 1] += Temp[i] / 10;
BigNum[i] = Temp[i] % 10;
}
else BigNum[i] = Temp[i];
}
for(int i = MAX - 1; i >= 0; i--)//获取长度
{
if(BigNum[i] > 0)
{
NowLen = i;
break;
}
}
} int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
memset(BigNum, 0, sizeof(BigNum));
BigNum[0] = 1, NowLen = 0;//初值 初始长度
for(int i = 2; i <= n; i++)//模拟乘法
Multi(i); for(int i = NowLen; i >= 0; i--)//格式输出
printf("%d",BigNum[i]);
printf("\n");
} return 0;
}

  

HDOJ-1042 N!(大数乘法)的更多相关文章

  1. HDOJ 1042 N! -- 大数运算

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N(0 ≤ N ≤ 1 ...

  2. 51nod 1027大数乘法

    题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...

  3. [POJ] #1001# Exponentiation : 大数乘法

    一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: ...

  4. 用分治法实现大数乘法,加法,减法(java实现)

    大数乘法即多项式乘法问题,求A(x)与B(x)的乘积C(x),朴素解法的复杂度O(n^2),基本思想是把多项式A(x)与B(x)写成 A(x)=a*x^m+b B(x)=c*x^m+d 其中a,b,c ...

  5. 51 Nod 1027 大数乘法【Java大数乱搞】

    1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B的长度  ...

  6. 51 Nod 1028 大数乘法 V2【Java大数乱搞】

    1028 大数乘法 V2 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A ...

  7. hdu_1042(模拟大数乘法)

    计算n! #include<cstring> #include<cstdio> using namespace std; ]; int main() { int n; whil ...

  8. (母函数 Catalan数 大数乘法 大数除法) Train Problem II hdu1023

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. 大数乘法|2012年蓝桥杯B组题解析第六题-fishers

    (9')大数乘法 对于32位字长的机器,大约超过20亿,用int类型就无法表示了,我们可以选择int64类型,但无论怎样扩展,固定的整数类型总是有表达的极限!如果对超级大整数进行精确运算呢?一个简单的 ...

随机推荐

  1. HttpRuntime类

    HttpRuntime在ASP.NET处理请求中负责的是创建HttpContext对象以及调用HttpApplicationFactory创建HttpApplication. 其定义如下: publi ...

  2. Unattended Setup Software Components (无人值守安装软件组件)

    原文 http://social.technet.microsoft.com/Forums/windows/en-US/d4ad85b4-8342-4401-83ed-45cefa814ec5/una ...

  3. java 常用的验证方法帮助类

    import java.text.ParseException; import java.util.Collection; import java.util.Map; /** * 常用的验证方法帮助类 ...

  4. Course Schedule II 解答

    Question There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may ...

  5. RBF径向基神经网络——乳腺癌医学诊断建模

    案例描述 近年来疾病早期诊断越来越受到医学专家的重视,从而产生了各种疾病诊断的新方法.乳癌最早的表现是患乳出现单发的.无痛性并呈进行性生长的小肿块.肿块位于外上象限最多见,其次是乳头.乳晕区和内上象限 ...

  6. HDOJ-1017 A Mathematical Curiosity(淼)

    http://acm.hdu.edu.cn/showproblem.php?pid=1017 # include <stdio.h> int find(int n, int m) { in ...

  7. HttpURLConnection访问url的工具类

    java代码: import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; ...

  8. SQL Server 日期函数:某天是星期几?

    [鹏城万里] 发表于 www.sqlstudy.com 要得到某一天是星期几,需要用到 SQL Server 中的日期函数:datename(). 今天是星期几,例子 1: set language ...

  9. Android应用程序与SurfaceFlinger服务的连接过程分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/7857163 前文在描述Android应用程序和 ...

  10. VLC播放器架构剖析

    VLC采用多线程并行解码架构,线程之间通过单独的一个线程控制所有线程的状态,解码器采用filter模式.组织方式为模块架构 模块简述:libvlc                  是VLC的核心部分 ...