当前位置:网站首页>High precision factorial
High precision factorial
2022-07-01 09:39:00 【Sky upstream】
Description
use High precision method , seek N!N! The exact value of (NN Enter as normal integer ).
Input
10
Output
3628800
Samples
Input
10
output
3628800
#include<bits/stdc++.h>
using namespace std;
long long a[1000001],m,n,i,j,k,l=1,x;//l Length ;
int main()
{
cin>>n;
for(i=1;i<=1000;i++)// Here for the sake of time 1000;
{
a[i]=0;
}
a[1]=1;
for(i=1;i<=n;i++)
{
x=0;
for(j=1;j<=l;j++)
{
a[j]=a[j]*i+x;
x=a[j]/10;
a[j]=a[j]%10;
}
while(x>0)
{
l++;
a[l]+=x;
x=a[l]/10;
a[l]=a[l]%10;
}
}
for(i=l;i>=1;i--)
{
cout<<a[i];
}
return 0;
}
In fact, the basic principle of utilization is : A character array , An operation , loop ;
You can try to debug the program to explore ;
边栏推荐
- OSPF - virtual link details (including configuration commands)
- Installation and use of NoSQL database
- LeetCode 344. Reverse string
- Latex插入的eps图片模糊解决方法
- Implementation and application of queue
- tensorrt yolov5_ trt. Py comments
- Some tools used in embedded development
- The market is relatively weak recently
- NoSQL数据库的安装和使用
- phpexcel 里 获取某一列的列表 获取某一列的字母
猜你喜欢
随机推荐
Rich text interpolation
SQL learning notes (01) - basic knowledge of database
集成积木报表报错 org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常
Problems caused by delete and delete[]
Postgraduate entrance examination vocabulary 2023 sharing (1)
ES6 const essence and completely immutable implementation (object.free)
Concept of digital currency
LeetCode 344. Reverse string
ES6 decoupling top-level objects from windows
HMS Core音频编辑服务3D音频技术,助力打造沉浸式听觉盛宴
[pytorch] 2.4 convolution function nn conv2d
苹果放大招!这件事干的太漂亮了……
奇怪,为什么ArrayList初始化容量大小为10?
嵌入式开发用到的一些工具
JS scope chain and closure
Strange, why is the ArrayList initialization capacity size 10?
js原型陷阱
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
Record a redis timeout
PHP merges multiple arrays. The same element takes the intersection of different elements to form an array









