HDU 1042 N!(高精度计算阶乘)
来源:互联网 发布:巧克力哪一款好吃知乎 编辑:程序博客网 时间:2024/05/17 04:39
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
123
126
题意:
就是求n的阶乘。
思路:
开一个数组模拟乘法运算即可。
#include<iostream>#include<cstdio>#include<string>#include<cmath>#include<cstring>using namespace std;const int mx = 41000;int a[mx];int main (){int n;while(scanf("%d",&n) != EOF){memset(a, 0, sizeof(a));a[0] = a[1]= 1;for(int i=2 ;i <= n; i++){int c = 0;for(int j = 1; j < mx; j++){int te = a[j] * i + c;a[j] = te % 10;c = te / 10;}}int tt;for(int i = mx-1; i>0; i--)if(a[i] != 0) {tt = i;break;} for(int i = tt; i > 0;i--)printf("%d",a[i]);puts("");}}
阅读全文
0 0
- HDU 1042 N!(高精度计算阶乘)
- HDU 1042 N!(高精度计算阶乘)
- HDU 1042 N! 阶乘 高精度(java)
- 高精度计算-n的阶乘
- hdu - 1042 - N!(高精度计算)
- HDU 1042 大数据、高精度,求n的阶乘
- 高精度-HDU-1042-N!
- 九度OJ 1076:N的阶乘(高精度计算)
- 高精度-n的阶乘
- 阶乘计算(高精度)
- 阶乘高精度计算
- 高精度N的阶乘-N!
- hdu 1042 N! 高精度运算
- Hdu 1042 N! (高精度数)
- HDU 1042 N!(高精度)
- hdu 1042 N! 高精度乘法
- HDU 1042 N!(大数阶乘)
- 高精度问题--n的阶乘
- 如何安装ionic
- 基于TCP的多人聊天工具
- Swift3.0 通知
- Activity处理返回结果
- js事件流
- HDU 1042 N!(高精度计算阶乘)
- 全面升级Android面试之webview面试题集
- Magento ver. 1.9.2.4 .htaccess配置301不起作用
- 1075-Incorrect table definition;there can be only one auto column and it must be defined as a key
- faster rcnn 训练与测试
- 经典java面试题(1)
- 字节流读入
- 欢迎使用CSDN-markdown编辑器
- Python读取TXT文件问题