> 其他 >
n的阶乘问题
1、n的阶乘定义为n!=1*2*3*……*n 如3!=6
通常最后会有很多0,如5!=120 最后有一个0,现在统计n!去除末尾的0后,最后k位是多少?
如果n!不止k位,则输出最后k位,如果不足k位,则将剩下的全部输出
输入n,k
输入:7,2
输出:04
人气:247 ℃ 时间:2020-03-18 05:17:44
解答
program chy1;const maxn=1000;var a:array[0..maxn]of longint;i,j,n,e,m,t,s,q:longint;beginreadln(n);a[0]:=1;for i:=1 to n do begine:=0;for j:=0 to a[maxn] do begine:=e+a[j]*i;a[j]:=e mod 10;e:=e div 10...
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版