Problem Description

输出N的阶乘。(注意时间限制150ms&&注意不能打表后输出)

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

Input

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

Output

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

Sample Input

1
2

Sample Output

1
2
 #include <iostream>
#include <stdio.h>
using namespace std;
#define ll long long
int main(){
ll n;
while(cin >> n){
ll cmp = ;
string str = "";
for(int i = ; i <= n; i++){
int x = i;
while(x% == ){
if(x% == ){
x /= ;
}
else cmp /= ;
x /= ;
str += '';
}
cmp *= x;
}
cout << cmp << str << endl;
}
}

N! (大数,优化)的更多相关文章

  1. HDU 5047 Sawtooth(大数优化+递推公式)

    http://acm.hdu.edu.cn/showproblem.php?pid=5047 题目大意: 给n条样子像“m”的折线,求它们能把二维平面分成的面最多是多少. 解题思路: 我们发现直线1条 ...

  2. MongoDB之索引

    索引是用来加快查询的,这里不解说索引的原理和数据结构.事实上大部分数据库的索引就是B+Tree,想要了解的同学能够看索引原理,要掌握怎样为查询配置最佳索引会有些难度. MongoDB索引差点儿和关系型 ...

  3. ACM学习历程—HDU 5446 Unknown Treasure(数论)(2015长春网赛1010题)

    Problem Description On the way to the next secret treasure hiding place, the mathematician discovere ...

  4. 大数计算_BigNum优化_加减乘除乘方取余_带注释_数组

    #include <iostream> #include <algorithm> #include <cstring> #include <cstdlib&g ...

  5. nyoj28 大数阶乘 亿进制优化

    思路:刚开始用的十进制模拟手算加法,超时了.然后想到刘汝佳大哥书上面用的亿进制能够加速大数运算,果然180ms过掉了. 亿进制与十进制相同,只不过是把八位看做一位,例如6464654654165,看成 ...

  6. 深入理解MySql子查询IN的执行和优化

    IN为什么慢? 在应用程序中使用子查询后,SQL语句的查询性能变得非常糟糕.例如: SELECT driver_id FROM driver where driver_id in (SELECT dr ...

  7. 【夯实Nginx基础】Nginx工作原理和优化、漏洞

    本文地址 原文地址 本文提纲: 1.  Nginx的模块与工作原理    2.  Nginx的进程模型    3 . NginxFastCGI运行原理        3.1 什么是 FastCGI   ...

  8. 转载:SqlServer数据库性能优化详解

    本文转载自:http://blog.csdn.net/andylaudotnet/article/details/1763573 性能调节的目的是通过将网络流通.磁盘 I/O 和 CPU 时间减到最小 ...

  9. 【转】【MySql】MySql优化要点

    如今随着互联网的发展,数据的量级也是撑指数的增长,从GB到TB到PB.对数据的各种操作也是愈加的困难,传统的关系性数据库已经无法满足快速查询与插入数据的需求.这个时候NoSQL的出现暂时解决了这一危机 ...

随机推荐

  1. Windows Server 2008 R2微软官方下载

    注意:Windows Server 2008 R2仅有64位版本. 以下下载地址为Windows Server 2008 R2 RTM Build 7600.16385的评估版本,此版本可免费试用18 ...

  2. 什么是 BULK INSERT

    MSDN的解释: 在 SQL Server 中以用户指定的格式将数据文件导入到数据库表或视图中. 语法: BULK INSERT [ database_name . [ schema_name ] . ...

  3. import模块

    一.在import模块的时候发生的事情 1.寻找模块2.如果找到了,就开辟一块空间,执行这个模块3.把这个模块中用到的名字都录到新开辟的空间中4.创建一个变量来引用这个模块中 二.注意事项: *1.模 ...

  4. R语言-画散点图

    plot()函数 plot(cars$dist~cars$speed,           # y~x main="XXX",                            ...

  5. linux 挂载磁盘

    挂在磁盘操作(还有一个300G的盘没显示出来): [root@iZgo67bo9s3uaijzqrgbaxZ ori]# df -h  Filesystem            Size  Used ...

  6. java-学习7

          数组的定义及使用 public class TestArr { public static void main(String[] args) { //声明数组 double array1[ ...

  7. php正则替换双引号里面的字符

  8. CSS Media Query

    [CSS Media Query] CSS Media Queries are a feature in CSS3 which allows you to specify when certain C ...

  9. 【C++】STL算法之remove_if

    之前写过这样一段代码: auto iter=remove_if(AllEdges.begin(),AllEdges.end(),[&](Edge* edge){return _isEedge( ...

  10. vue confirm确认

    this.$confirm('您确定删除吗?').then(_ => { do something ... (确认) }).catch(_ => { do something ... (取 ...