题目描述

输出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. mysql-utilities1.6

    mysql-utilities1.6 mysql-utilities是一个用python编写的mysql工具集 mysql-utilities是Oracle专门开发的 一共有28个工具 /usr/bi ...

  2. Spark log4j日志配置详解(转载)

    一.spark job日志介绍    spark中提供了log4j的方式记录日志.可以在$SPARK_HOME/conf/下,将 log4j.properties.template 文件copy为 l ...

  3. [django]form的content-type(mime)

    form默认的content-type是 'application/x-www-form-urlencoded' 可以修改为多文档: enctype即为mime类型 <form action=& ...

  4. Day5 函数递归,匿名、内置行数,模块和包,开发规范

    一.递归与二分法 一.递归 1.递归调用的定义 递归调用:在调用一个函数的过程中,直接或间接地调用了函数本身 2.递归分为两类:直接与间接 #直接 def func(): print('from fu ...

  5. Linux简单版重要安装步骤

    1.稍后安装操作系统 2.自定义硬件 3.选择镜像(mini) 4.开机选择第一个 5.skip(跳过检测) 6.是,忽略所有数据 7.配置网络 8.设置root用户密码 9.使用所有空间 10.写入 ...

  6. Linux下samba服务搭建

    参考: https://www.cnblogs.com/lxyqwer/p/7271369.html https://www.cnblogs.com/liulipeng/p/3406352.html ...

  7. TortoiseGit推送代码到Gerrit的过程

    gerrit的安装不在本博客的说明范围中,本博客阐述的是使用TortoiseGit 提交代码到gerrit上的步骤和配置. 一.Git 说明:这个工具只要用来做一个仿真的linux环境,可以执行大部分 ...

  8. AC自动机模板2

    题目链接:https://www.luogu.org/problemnew/show/P3796 #include <cstdio> #include <cmath> #inc ...

  9. 数据分析与挖掘 - R语言:贝叶斯分类算法(案例三)

    案例三比较简单,不需要自己写公式算法,使用了R自带的naiveBayes函数. 代码如下: > library(e1071)> classifier<-naiveBayes(iris ...

  10. Linux:系统文件目录

    目录结构 bin:命令类目录 命令 系统操作 清屏:clear.ctrl+L 进程: # $(ps -ef | grep hnlinux) //方法一 过滤出hnlinux用户进程 #kill -u ...