siuuuuu @ 2023-06-18 18:26:41
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
#define maxn 100
using namespace std;
struct Bigint{
int len,a[maxn];
Bigint(int x=0){
memset(a,0,sizeof(a));
for(len=1;x;len++)
a[len]=x%10,x/=10;
len--;
}
int &operator[](int i){
return a[i];
}
void flatten(int L){
len=L;
for(int i=1;i<=len;i++)
a[i+1]+=a[i]/10,a[i]%=10;
for(;!a[len];)
len--;
}
void print(){
for(int i=max(len,1);i>=1;i--)
printf("%d",a[i]);
}
};
Bigint operator+(Bigint a,Bigint b){
Bigint c;
int len=max(a.len,b.len);
for(int i=1;i<=len;i++)
c[i]+=a[i]+b[i];
c.flatten(len+1);
return c;
}
Bigint operator*(Bigint a,Bigint b){
Bigint c;
int len=a.len;
for(int i=1;i<=len;i++)
(Bigint)c[i]=a[i]*b;
c.flatten(len+11);
return c;
}
int main(){
int m;
Bigint ans(0),fac(1);
cin>>m;
for(int i=1;i<=m;i++){
fac=fac*i;
ans=ans+fac;
}
ans.print();
return 0;
}
by Wf_yjqd @ 2023-06-18 18:31:25
请问您 fac=fac*i;
?
by Querainy @ 2023-06-18 18:33:51
@听取MLE声一片
by Wf_yjqd @ 2023-06-18 18:46:37
6,呼叫教皇是吧。
by Light_az @ 2023-06-18 18:47:24
《首尾呼应》
by Wf_yjqd @ 2023-06-18 18:48:06
您把一个数组*一个数且没有重载运算符啊。
by Auto_Accepted @ 2023-06-18 18:48:40
《首 尾 呼 应》
《呼 叫 教 皇》
by 听取MLE声一片 @ 2023-06-18 19:07:28
?
by Iam1789 @ 2023-06-18 21:00:33
@听取MLE声一片 大帝别自搜了