Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created November 1, 2012 15:19
Show Gist options
  • Save Abreto/3994267 to your computer and use it in GitHub Desktop.
Save Abreto/3994267 to your computer and use it in GitHub Desktop.
UVaOJ 568 - Just the Facts
/* UVaOJ 568 - Just the Facts */
#include <stdio.h>
int main(void)
{
int N = 0;
while( scanf("%d", &N)==1 )
{
int i = 0;
long long facts = 1;
for(i = 1;i < N+1;i++)
{
facts *= i;
while(facts%10 == 0) facts /= 10; // 舍弃末尾所有的〇
facts %= 100000000; // 取最后8位
}
printf("%5d -> %lld\n", N, facts%10);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment