题目描述

输出N的阶乘。(注意时间限制150ms&&注意不能打表后输出,赛后我们会检查代码,如有发现,该位同学总分记0分处理)

打表的定义:在本地主机预先计算出了每个值对应的答案,并把输入和输出的映射直接写入所提交的代码。

输入

多组输入到文件结尾
每组输入一个整数n,(0<=n<=23)。

输出

每组测试数据输出一行,为n!。

样例输入
1
2
样例输出
1
2 题解:有两种办法,一个是用c++的高精度来写,第二种是用long long int去存乘积,但是不要全部都存,
把计算过程中所有的因子10提取出来(PS:sum只存去除后缀0的数),就是说例如如果遇到了5,就把sum除以2,
把标志末尾有多少个0的计数器++,最后吧sum输出,在循环输出全部的0
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
const int N=1e6+;
const int mod=1e9+;
int main()
{
ll n;
while(cin>>n){
ll pre=;
string s="";
for(int i=;i<=n;i++){
int x=i;
while(x%==){
if(x%==)
x/=;
else
pre/=;
x/=;
s+='';
}
pre*=x;
}
cout<<pre<<s<<endl;
}
return ;
}

最新文章

  1. EXT.NET 使用总结(2) ---TreePanel(带右键菜单,节点自定义属性)
  2. 移动web开发之视口viewport
  3. bzoj4318OSU &amp;tyvj1952 Easy
  4. Search Insert Position [LeetCode]
  5. Django开发博客- 部署
  6. root密码
  7. 一个类搞定UIScrollView那些事
  8. 图论:(Code Forces) Graph and String
  9. webpack 1.x 学习总结
  10. [Android编程心得] Camera(OpenCV)自动对焦和触摸对焦的实现
  11. iOS ReplayKit 录屏 框架的使用
  12. 把html页面转化成图片——html2canvas
  13. 最简单的TTcpServer与TTcpClient通信实例-Delphi
  14. 对SVC和SVR的理解
  15. RxJava【过滤】操作符 filter distinct throttle take skip first MD
  16. 豆瓣上9分以上的IT书籍-编程技术篇
  17. [USACO08JAN]Telephone Lines
  18. POJ2564:Edit Step Ladders
  19. CentOS 6.9关闭NetworkManager服务
  20. 【转】10 个MySQL数据库备份教程推荐

热门文章

  1. 用laravel dingo/api创建简单的api
  2. 使用python实现日志功能
  3. ABS PBT POM材质键冒
  4. PinyinUtil
  5. linux中cmake语法的学习
  6. create genil component
  7. abap异常处理 , update module
  8. 96A
  9. 块结构在文件中的表示IOB【转载】
  10. 软RAID管理命令mdadm详解