poj 1604 Just the Facts
来源:互联网 发布:matlab 矩阵符号运算 编辑:程序博客网 时间:2024/04/29 19:01
//通过打表就OK,求阶乘的末尾不为0的第一位数字! #include <iostream>#include <cstdio>#include <memory.h>using namespace std;int ans[10010];void solve(){ int i, mult; memset(ans, 0, sizeof(ans)); ans[1] = 1; mult = 1; for (i = 2; i <= 10005; i++){ mult *= i; //将阶乘得出的结果去掉末尾的0 while (mult % 10 == 0){ mult /= 10; } mult %= 100000;//对结果取模,是为了在求阶乘的时候产生溢出! ans[i] = mult % 10;//得出结果 }}int main(){ int num; solve(); while (cin >> num){ printf("%5d -> %d\n", num, ans[num]); } system("pause");}
- poj 1604 Just the Facts
- poj 1604 Just the Facts
- POj 1604 Just the Facts
- [POJ 1604] Just the Facts
- poj 1604 Just the Facts(大数)
- POJ 1604 Just the Facts @Z
- POJ 1604 Just the Facts JAVA .
- POJ 1604 Just the Facts 笔记
- Just the Facts - 1604
- POJ 1604 Just the Facts 阶乘最后非0位
- poj 1604 Just the Facts(简单数学)
- 1604 Just the Facts (高精度) (?)
- zoj1222 Just the Facts
- 1199: Just the Facts
- Just the Facts(P1604)
- 568 - Just the Facts
- 568 - Just the Facts
- 568 - Just the Facts
- Struts配置异常at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory
- 设计模式笔记——Iterator
- IOS开发:关于UILabel阴影设置的问题
- hdu:4360(spfa)求各种状态的最短路
- ORACLE中decode函数的用法
- poj 1604 Just the Facts
- FZU:Problem 1864 Christmas Machine
- Linux 下模拟Ping命令的 C 实现
- js获取当前月的第一天和最后一天
- AutoBuild系统的改进
- 绘制实心圆
- Aix IPSEC 策略介绍
- 串行通信与重叠I/O
- linux启动自动运行程序