博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu1042
阅读量:2232 次
发布时间:2019-05-09

本文共 575 字,大约阅读时间需要 1 分钟。

#include<stdio.h>
#include<iostream>
using namespace std;
int a[8000];
int main()
{
int n;
int i;
while(scanf("%d",&n)!=EOF)//碰到有EOF的时候一定要用scanf。不要用cin>>n&&n这样的的,不让这样的错误你非常难发现
{
if(n==0||n==1) 
{
cout<<"1\n";
continue;
}
memset(a,0,sizeof(a));
int count=2;
int r;
a[0]=1;
int bit=1;
for(i=2;i<=n;i++)
{
r=0;
for(int j=0;j<bit;j++)
{
int t=a[j]*i+r;
r=t/100000;
a[j]=t%100000;
}
if(r>0)
{
a[bit++]=r;
}
}
int j=0;
for(j=8000;j>=0;j--)if(a[j]!=0)break;
cout<<a[j];
for(i=j-1;i>=0;i--)
{
printf("%05d",a[i]);
}
cout<<endl;
}
}

转载于:https://www.cnblogs.com/ljbguanli/p/6880224.html

你可能感兴趣的文章
(PAT 1019) General Palindromic Number (进制转换)
查看>>
(PAT 1073) Scientific Notation (字符串模拟题)
查看>>
(PAT 1080) Graduate Admission (排序)
查看>>
Play on Words UVA - 10129 (欧拉路径)
查看>>
mininet+floodlight搭建sdn环境并创建简答topo
查看>>
【linux】nohup和&的作用
查看>>
Set、WeakSet、Map以及WeakMap结构基本知识点
查看>>
【NLP学习笔记】(一)Gensim基本使用方法
查看>>
【NLP学习笔记】(二)gensim使用之Topics and Transformations
查看>>
【深度学习】LSTM的架构及公式
查看>>
【python】re模块常用方法
查看>>
剑指offer 19.二叉树的镜像
查看>>
剑指offer 20.顺时针打印矩阵
查看>>
剑指offer 21.包含min函数的栈
查看>>
剑指offer 23.从上往下打印二叉树
查看>>
剑指offer 25.二叉树中和为某一值的路径
查看>>
剑指offer 60. 不用加减乘除做加法
查看>>
Leetcode C++《热题 Hot 100-15》437.路径总和III
查看>>
Leetcode C++《热题 Hot 100-17》461.汉明距离
查看>>
Leetcode C++《热题 Hot 100-18》538.把二叉搜索树转换为累加树
查看>>