HDU 1066 Last non-zero Digit in N!(数论,大数,wait)
2024-10-21 13:37:06
The expression N!, read as "N factorial," denotes the product of the first N positive integers, where N is nonnegative. So, for example,
N N!
0 1
1 1
2 2
3 6
4 24
5 120
10 3628800
N N!
0 1
1 1
2 2
3 6
4 24
5 120
10 3628800
For this problem, you are to write a program that can compute the last non-zero digit of the factorial for N. For example, if your program is asked to compute the last nonzero digit of 5!, your program should produce "2" because 5! = 120, and 2 is the last nonzero digit of 120.
InputInput to the program is a series of nonnegative integers, each on its own line with no other letters, digits or spaces. For each integer N, you should read the value and compute the last nonzero digit of N!.
OutputFor each integer input, the program should print exactly one line of output containing the single last non-zero digit of N!.
Sample Input
1
2
26
125
3125
9999
Sample Output
1
2
4
8
2
8
最新文章
- 解决VirtualBox只能安装32位系统的问题
- 用php获取本周,上周,本月,上月,本季度日期的代码
- AS3从入门到放弃
- Less里css表达式的写法
- OPENSSL安装 以及使用openssl中的AES加密和解密
- Ubuntu下安装Nginx,PHP5(及PHP-FPM),MySQL
- 转:栈和队列小知识【STL用法】
- [python] 视频008
- 值得关注的 10 个 Python 英文博客
- Delphi 线程resume 不能调用Execute
- Histats申请Counter网站计数器 - Blog透视镜
- JS判断当前使用设备是pc端还是web端(转MirageFireFox)
- __x__(44)0910第六天__表单
- CentOS 使用firewalld打开防火墙与端口
- WiFi-ESP8266入门http(2-1)文件系统-复杂结构的网页
- 初始Redis
- web安全之机器学习入门——1.环境搭建
- 简单理解jQuery中$.getJSON、$.get、$.post、$.ajax用法
- 在 Roslyn 分析语法树时添加条件编译符号的支持
- 精《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #4 如何使用Git