什么也不输出???
查看原帖
什么也不输出???
524091
dami826楼主2022/12/30 14:59
#include<bits/stdc++.h>
using namespace std;
int A[101],B[101],C[101],S[101],a=1,b,c,s;
void carry(int *p,int o){
	for(int i=1;i<=o;i++){
		if(*p>=10){
			*(p+1)+=*p/10;
			*p%=10;
		}
		p++;
	}
}
void hp_multipication(){
	for(int i=0;i<=a-1;i++){
		for(int j=0;j<=b-1;j++){
			C[i+j]+=A[i]+B[j];
		}
	}
	carry(&C[0],c);
	if(C[c]>0){
		c++;
	}
}
void hp_plus(){
	for(int i=0;i<=s-1;i++){
		S[i]+=B[i];
	}
	carry(&S[0],s);
}
int main(){
	int n;
	scanf("%d",&n);
	A[0]=1;
	for(int k=1;k<=n;k++){
		int m=k;
		a=0;
		while(m>0){
			A[a]=m%10;
			a++;
			m/=10;
		}
		hp_multipication();
		s=b;
		b=c;
		for(int i=0;i<=c-1;i++){
			B[i]=C[i];
		}
		hp_plus();
	}
	for(int i=s-1;i>=0;i--){
		printf("%d",S[i]);
	}
    return 0;
}
2022/12/30 14:59
加载中...