题意:
求一个阶乘除以阶乘的个位数。
POINT:
这种题肯定不是暴力去做。一开始想找循环节,仔细一想还是很慢。
只要乘以了末尾有0的数,那么答案肯定是0,其他就一个for循环,顶多循环9次。
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include<algorithm>
using namespace std;
#define LL long long
const int maxn = 2222;
int main()
{
LL ans=1;
LL a,b;
scanf("%lld %lld",&a,&b);
for(LL i=a+1;i<=b;i++){
if(i%10==0){
ans=0;
break;
}
else{
ans=ans*i%10;
}
}
printf("%lld\n",ans);
}