为啥编译失败!!!

P1009 [NOIP1998 普及组] 阶乘之和

bacfdml @ 2024-12-28 11:00:42

#include <bits/stdc++.h>
using namespace std;
const int maxn=51;
int main()
{
 int n,s=0,x[maxn];
 cin>>n;
 memset(x,1,sizeof(x))
 for(int i=1;i<=n;i++){
  for(int j=1;j<=i;j++){
   x[i]*=j;
  }
 }
 for(int i=1;i<=n;i++)
 {
  s+=x[i];
 }
 cout<<s;
 return 0;
}

by McdullWang @ 2024-12-28 11:03:19

第8行没加分号


by a_small_OIer @ 2024-12-28 11:22:07

memset(x,1,sizeof(x))

没加分号

#include <bits/stdc++.h>
using namespace std;
const int maxn=51;
int main()
{
 int n,s=0,x[maxn];
 cin>>n;
 memset(x,1,sizeof(x));
 for(int i=1;i<=n;i++){
  for(int j=1;j<=i;j++){
   x[i]*=j;
  }
 }
 for(int i=1;i<=n;i++)
 {
  s+=x[i];
 }
 cout<<s;
 return 0;
}

就对了


by ___xuzhimo___ @ 2024-12-28 11:29:14

@bacfdml@McdullWang@a_small_OIer 这道题要用高精度,你们看看数据范围


by bacfdml @ 2024-12-28 12:49:54

@McdullWang@a_small_OIer@xuzhimo谢谢


|