因为痛,所以叫青春

我有一个梦想:穷屌丝变身富屌丝
uva568 Just the Facts
View Code
#include<stdio.h>
#include<string.h>
int main()
{
    int n, i, j, k;
    long long s = 0;
    while(scanf("%d",&n) != EOF)
    {
        printf("%5d -> ", n);
        s = 1;
        for(i = 2;i <= n; i++)
        {
            s *= i;
            while(s%10 == 0)
                s /= 10;
            if(s > 1000000000000)
                s %= 1000000000000;
        }
        printf("%lld\n",s%10);
    }
    return 0;
}

posted on 2012-07-31 21:29  Nice!  阅读(161)  评论(0编辑  收藏  举报