N!高精度
来源:互联网 发布:下周主要财经数据 编辑:程序博客网 时间:2024/04/30 07:14
计算N!
Problem:A
Time Limit:6000ms
Memory Limit:65536K
Description
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
Input
One N in one line, process to the end of file.
Output
For each N, output N! in one line.
Sample Input
123
Sample Output
126
Hint
输入的N小于10000,可以输入,用INT型的大数就行,用数值型的高精度!
Source
#include <iostream>#include <string.h>using namespace std;///求N的阶const int maxn=50005;int f[maxn];int main(){ int n,c; while(cin>>n) { memset(f,0,sizeof(f)); f[0]=1; int i; for( i=1;i<=n;i++) { c=0; for(int j=0;j<=maxn;j++) { int s=f[j]*i+c; f[j]=s%10; c=s/10; } } for( i=maxn;i>=0;i--) { if(f[i]!=0) { break; } } for(;i>=0;i--) { cout<<f[i]; } cout<<endl; } //cout << "Hello world!" << endl; return 0;}
阅读全文
0 0
- 高精度N!
- N!高精度
- N!高精度
- 高精度N的阶乘-N!
- hdoj 1042 N!(高精度)
- 高精度之求N!
- N!(高精度计算)
- 高精度-HDU-1042-N!
- 高精度求N!
- n!(高精度)
- 高精度计算N!
- 高精度-n的阶乘
- 高精度m^n(pku3199)
- 高精度N进制转M进制
- poj 1001 高精度R^N
- poj 2389(高精度)N!
- hdu 1042 N! 高精度运算
- 【高精度】2的n次方
- [LeetCode]257. Binary Tree Paths
- mysql 数据导入导出
- Spring 源码粘贴4
- tensorflow 学习笔记1-最邻近实现(NN)
- 【2017年5月17日】js 事件触发大全
- N!高精度
- android volley
- 小白之路
- Qt QTableView设置各行的背景颜色
- 互联网支付系统整体架构详解
- Java面向对象的六原则法则
- WebGL基础简明教程1-简介
- a标签怎么去下划线以及实现点击前和点击后不变色
- 求两个链表的第一个公共结点各种情况及三种思路分析