568

小水题一道~

//============================================================================
// Name        : 568.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

long long ans;
int n;

int main() {
	freopen("a.txt", "r", stdin);
	while(scanf("%d", &n)!=EOF){
		printf("%5d -> ", n);
		ans = 1;
		for(int i = 1;i <= n;i++){
			if(ans * i >= (long long)1e15){
				ans = (ans*i)%((long long)1e15);
			}
			else ans = ans*i;
			while(ans%10 == 0){
				ans /= 10;
			}
		}
		printf("%d\n", ans%10);
	}
	return 0;
}

  

posted @ 2011-07-23 21:39  KOKO's  阅读(134)  评论(0编辑  收藏  举报