题目描述

输出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 ;
}

JustOj 2043: N!的更多相关文章

  1. HDU 2043 密码

    http://acm.hdu.edu.cn/showproblem.php?pid=2043 Problem Description 网上流传一句话:"常在网上飘啊,哪能不挨刀啊-" ...

  2. JZYZOJ 2043 多项式除法和取余 NTT 多项式

    http://172.20.6.3/Problem_Show.asp?id=2043 最开始用了FFT,交上去全tle和wa了(tle的比较多),测了一组数据发现求逆元的过程爆double了(毕竟系数 ...

  3. AC日记——猴子 cogs 2043

    2043. 猴子 ★★   输入文件:monkeya.in   输出文件:monkeya.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 有n只猴子,第一只尾巴挂在树上 ...

  4. 致初学者(三): HDU 2033~ 2043题解

    下面继续给出HDU 2033~2043的AC程序,供大家参考.2033~2043这10道题就被归结为“ACM程序设计期末考试(2006/06/07) ”和“2005实验班短学期考试 ”. HDU 20 ...

  5. hdu 2043

    Ps:自己写了以后又去看了下苏哥的....改进版的....学到东西,直接套用了. 代码: #include "stdio.h"#include "string.h&quo ...

  6. Justoj 2388最短区间 贪心

    2388: 最短区间 Time Limit: 1 s      Memory Limit: 128 MB Submit My Status Problem Description 有M种不同颜色的气球 ...

  7. Justoj 2389: 拼接三角形 二分查找

    2389: 拼接三角形 时间限制: C/C++ 1 s      Java/Python 3 s      内存限制: 128 MB      答案正确: 7      提交: 21 提交 我的状态 ...

  8. HDU - 2043密码 水题

    密码 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  9. hdoj:2043

    #include <iostream> #include <string> using namespace std; bool judgeSize(string str) { ...

随机推荐

  1. Linux安装go

    在 http://golang.org/dl/下载最新的linux版本,并把它提取到/usr/local目录,在此目录下进行解压缩 $ sudo tar -xzf go1.9.1.linux-amd6 ...

  2. [Shapefile C Library]读写shp图形(C++&.net Wapper)

    ShapeLib的.net Wapper版可以在官网下载到,在WorldWind中也有使用.ORG据说也是使用的ShapeLib实现的shp文件的读写. 官网:http://shapelib.mapt ...

  3. [sh]basename&dirname截取路径和文件名&case参数选项

    给出全路径,取出路径和文件名 basename使用示例 http://codingstandards.iteye.com/blog/840784 示例一 [root@web ~]# basename ...

  4. maven项目中添加Tomcat启动插件

    在pom.xml文件中添加如下配置: <!-- 配置tomcat插件,pom.xml里配置 --> <build> <plugins> <plugin> ...

  5. BI-LSTM and CRF using Keras

    问题1:CUDA_ERROR_OUT_OF_MEMORY: How to activate multiple GPUs from Keras in Tensorflow import keras.ba ...

  6. elasticsearch 处理index 一直INITIALIZING状态

    elasticsearch一个节点异常重启后有一个index恢复的过程中状态一直INITIALIZING 处理方法 PUT index_name/_settings { "index&quo ...

  7. 24-Python3 OS

    24-Python3 OS ''' OS文件/目录方法 ''' ##os.access():检验权限模式 fo1 = open('/Users/ligaijiang/PycharmProjects/f ...

  8. SDWebImage代码赏析

    过NSOperationQueue来控制 为了保护变量,使用大量了sychronized 读的时候使用了dispatch_sync dispatch_sync(sself.barrierQueue, ...

  9. R安装package报ERROR: a 'NAMESPACE' file is required

    R安装package报错: [root@Hadoop-NN-01 mysofts]# R CMD INSTALL trimcluster_0.1-1.tar.gz * installing to li ...

  10. Web API 入门 二 媒体类型

    还是拿上面 那篇 Web API 入门 一  的那个来讲 在product类中加一个时间属性