题解 1285: 阶乘末尾的K位

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

P1018 (C语言代码)

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int b[21],s[100];int n,k;int main(){ int i,j,t,flag; int w,r,q; scan……

P1018 (C++代码)

摘要:#include <iostream> using namespace std; int main() { int k, n; long long sum = 1; cin >> n……

P1018 (C语言代码)

解题思路:先求出阶乘,然后去掉后面的0,再把数字转换为字符串,然后再取后面的子串即可。注意事项:转换字符串时使用了sprintf函数,把数字转换为字符串,该函数有3个参数:第1个参数是要保存转换结果字符串的字符数组,第2个参数是输出格式,第3个参数是要转换的整数。

P1018 (C语言代码)

摘要:解题思路:注意事项:参考代码:#include<stdio.h> int main() {  int a[100],cnt=0,n,m;  long long sum=1;  scanf("……

P1018-题解(C++代码)

字符串的题目还是先分解题目首先需要求数字的阶乘用的函数就是longlong阶乘longlong类型是为了防止溢出然后我们需要去掉末尾0只需要判断能否被10整除就可以了然后循环/=10就可以去掉末尾0然后我们还需要求出位数如果位数resn>>k;longlongsum=jiechen(n);while(

阶乘末尾的K位

摘要:解题思路:注意事项:参考代码:#include <stdio.h>long long a[100];int main(){         int n,m,k=0,i;         long lo……

阶乘末尾的K位

解题思路:注意事项:参考代码:frommathimport*n,k=map(int,input().split())a=str(factorial(n))whilea.endswith('0'):a=a[:len(a)-1]print(a[-k:])

P1018-题解(C语言代码)

#includeintmain(void){longlongpro=1;inti=0,j=0,n=0,k=0;charstr[16]={'\0',};scanf("%d%d",&n,&k);for(i=n;i>=1;--i){pro*=i;}while(0==pro%10){pro/=10;}for(