/* 568 C "Just the Facts" */
/* @BEGIN_OF_SOURCE_CODE */
#include <stdio.h>
#define FACT_UPTO 10001
int n, fact_lnzd[FACT_UPTO] ;
void precompute(void)
{
int i, fact ;
fact_lnzd[0] = fact_lnzd[1] = fact = 1 ;
for (i=2; i<=FACT_UPTO; i++) {
fact = fact * i ;
while (fact%10==0)
fact /= 10 ;
fact = fact%100000 ;
fact_lnzd[i] = fact%10 ;
}
}
int main()
{
precompute() ;
while (scanf("%d", &n) != EOF)
printf("%5d -> %d\n", n, fact_lnzd[n]) ;
return 0;
}
/* @END_OF_SOURCE_CODE */
Pages
Labels
01 Knapsack
(1)
Ad Hoc
(1)
Backtracking
(1)
Binary Search Tree
(1)
bits
(1)
Brute Force
(1)
codelib
(2)
Data Structures
(1)
Dijkstra
(1)
DP
(2)
Graphs
(1)
Heaps
(1)
Joseph
(1)
Maximum 1-D Sum
(1)
Maximum Contiguous Sum
(1)
Primes
(1)
Priority Queues
(1)
Recursion
(1)
Sieve of Atkins
(1)
UVaOJ Vol-102
(1)
UVaOJ Vol-109
(1)
UVaOJ Vol-5
(1)
Saturday, March 5, 2011
UVa 568 - Just the Facts
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment