请问各位大佬为什么这样写不行
查看原帖
请问各位大佬为什么这样写不行
856898
Cartier楼主2022/12/29 20:47
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=0;
	cin>>n;
	int A[100]={0};
	int B[100]={0};
	A[0]=1;
	B[0]=1;
	if(n==1){
		cout<<"1"<<endl;
		return 0;
	}
	else{
		for(int i=2;i<=n;i++){
			for(int j=0;j<100;j++){
				A[j]*=i;
			}
			for(int k=0;k<100;k++){
				if(A[k]>=10){
					A[k+1]=A[k+1]+A[k]/10;
					A[k]%=10;
				}
				B[k]=B[k]+A[k];
				if(B[k]>=10){
					B[k+1]+=B[k+1]+1;
					B[k]=B[k]-10;
				}
				
			}
		}
	}
	int p=99;
	while(B[p]==0){
		p--;
	}
	while(p>=0){
		cout<<B[p];
		p--;
	}
	return 0;
}
2022/12/29 20:47
加载中...