poj 1604 Just the Facts(简单数学)
2013-08-19 23:57
330 查看
题目连接:http://poj.org/problem?id=1604
解题思路:每次计算后去除后位0,以及保留5位长度。
#include <stdio.h>
#include <string.h>
int main() {
int n, sum;
while (scanf("%d", &n) == 1) {
sum = 1;
for (int i = 1; i <= n; i++) {
sum *= i;
while (sum % 10 == 0) {
sum = sum / 10;
}
sum = sum % 100000;
}
printf("%5d -> %d\n", n, sum % 10);
}
return 0;
}
解题思路:每次计算后去除后位0,以及保留5位长度。
#include <stdio.h>
#include <string.h>
int main() {
int n, sum;
while (scanf("%d", &n) == 1) {
sum = 1;
for (int i = 1; i <= n; i++) {
sum *= i;
while (sum % 10 == 0) {
sum = sum / 10;
}
sum = sum % 100000;
}
printf("%5d -> %d\n", n, sum % 10);
}
return 0;
}
相关文章推荐
- poj1604 Just the Facts
- poj 1604 Just the Facts
- POJ_1604_Just the Facts(阶乘末尾非0位)
- POJ 1604 Just the Facts @Z
- POJ 1604 Just the Facts 阶乘最后非0位
- 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
- 如何计算N!的最后一位非零数字(POJ 1604 Just the Facts)
- POJ 1604 Just the Facts JAVA .
- [POJ 1604] Just the Facts
- poj 1604 Just the Facts
- Just the Facts - 1604
- POJ 2242 The Circumference of the Circle 简单数学
- POJ 1273 Drainage Ditches POJ 1274 The Perfect Stall 最大流简单题
- POJ题目2282 The Counting Problem(数学)
- UVA 568-Just the Facts
- UVa 568 Just the Facts (数论&打表&不打表)