HD-ACM算法专攻系列(5)——N!
2024-08-31 11:01:47
题目描述:
源码:
#include"iostream"
using namespace std; int main()
{
int n, digit, carry, tmp;
int a[40000];
while(cin>>n)
{
if(n <= 1)
{
cout<<1<<endl;
}
else
{
a[0] = 1;
digit = 1;
for(int i = 2; i <= n; i++)
{
carry = 0;
for(int j = 0; j < digit; j++)
{
tmp = a[j] * i + carry;
a[j] = tmp % 10;
carry = tmp / 10;
}
while(carry > 0)
{
a[digit] = carry % 10;
digit++;
carry /= 10;
} }
for(int j = digit - 1; j >= 0; j--)
{
cout<<a[j];
}
cout<<endl;
}
}
return 0;
}
最新文章
- 第一课1、ROS
- Asm.Def点大兵
- Codeforces Round #272 (Div. 2) D. Dreamoon and Sets (思维 数学 规律)
- 分布式网站架构后续:zookeeper技术浅析
- 【CSS3】---练习制作导航菜单
- 学习记录:浏览器JAVASCRIPT里的WINDOWS,DOCUMNET
- 上传头像,界面无跳转,php+js
- 过滤HTML
- Java经典案例之-“最大公约数和最小公倍数”
- 新的表格展示利器 Bootstrap Table Ⅱ
- mybatis的搭建和注入spring的方式
- HTML知识点总结之div、section标签
- 错误问题:OpenGL version to old,GLViewinitWithRect(const stdbasic_stringchar,stdchar_traitschar,stdalloca
- java.util.Arrays类详解(源码总结)
- TODO 动态执行appium代码,便于修改和调试
- Mybatis-generator生成Service和Controller
- dos命令:系统命令
- 题目1441:人见人爱 A ^ B(二分求幂)
- centos LB负载均衡集群 三种模式区别 LVS/NAT 配置 LVS/DR 配置 LVS/DR + keepalived配置 nginx ip_hash 实现长连接 LVS是四层LB 注意down掉网卡的方法 nginx效率没有LVS高 ipvsadm命令集 测试LVS方法 第三十三节课
- 【OC底层】一个OC对象占用多少内存?
热门文章
- Spark SQL 编程API入门系列之SparkSQL的入口
- Centos7 minimal 系列之rabbitmq安装(八)
- C# web api 中过滤器的使用
- Asp.net mvc中使用配置Unity
- sql server 随机生成布尔值
- 大话主席(superslide和 touchslide)插件的使用
- [ RESTful ] [ API ] 有用的資訊
- Redis数据库入门基础,及优缺点介绍
- 搭建hadoop、hdfs环境--ubuntu(完全分布式)
- 洛谷T44252 线索_分治线段树_思维题