当前位置:网站首页>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 ;
边栏推荐
- PR training notes
- js函数arguments对象
- node. How to implement the SQL statement after JS connects to the database?
- Mikrotik Routeros Internet access settings
- JS prototype trap
- 树结构---二叉树2非递归遍历
- ES6 decoupling top-level objects from windows
- 【pytorch】nn. Crossentropyloss() and nn NLLLoss()
- 华为帐号多端协同,打造美好互联生活
- Postgraduate entrance examination vocabulary 2023 sharing (1)
猜你喜欢

Some tools used in embedded development

Who has the vision to cross the cycle?

集成积木报表报错 org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常

队列的实现和应用

Precautions for lvgl v8.2 string display on keil MDK (take little bear pie as an example)

The market is relatively weak recently

MapReduce programming basics
![Problems caused by delete and delete[]](/img/d9/a1c3e5ce51ef1be366a973aa42d1f0.png)
Problems caused by delete and delete[]

【pytorch】nn. Crossentropyloss() and nn NLLLoss()
![Clickhouse: Test on query speed of A-share minute data [Part 2]](/img/c8/42ba748d38546d3b0d2be9b33c5d0b.jpg)
Clickhouse: Test on query speed of A-share minute data [Part 2]
随机推荐
树结构---二叉树2非递归遍历
JS prototype trap
SQL learning notes (01) - basic knowledge of database
那个程序员,被打了。
Short circuit operator lazy evaluation
js原型继承仅可继承实例而非构造器
SDN_ Simple summary
121. thread scheduling: join() method and yield() method
phpexcel 里 获取某一列的列表 获取某一列的字母
Strange, why is the ArrayList initialization capacity size 10?
【leetcode】287. Find duplicates
Cortex M4 systick details
利用闭包实现私有变量
Differences between JS valueof and toString
LVGL V8.2字符串显示在Keil MDK上需要注意的事项(以小熊派为例)
Flinkv1.13实现金融反诈骗案例
【pytorch】transforms. Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
PHP code audit and File Inclusion Vulnerability
NoSQL数据库的安装和使用
A 419 error occurred in the laravel postman submission form. July 6th, 2020 diary.