算法训练 P0505
代码
//注意考虑可能会出现的情况!
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int x=1;
cin>>n;
for(int i=2;i<=n;i++)
{
x*=i;
while(x%10==0)
{
if(x%10 !=0)
break;
x/=10;
}
x=x%1000;
}
x=x%10;
cout<<x;
return 0;
}