为什么会50pts?

P1009 [NOIP1998 普及组] 阶乘之和

xxJoy0420 @ 2023-11-07 12:46:30

窒息啊,提交了无数次都还是WA!

#include<bits/stdc++.h>
using namespace std;
long long sc=1,re;
int n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            sc*=j;
        }
        re+=sc;
        sc=1;
    }
    cout<<re; 
    return 0;
}

请大佬们帮忙看一下!


by h_rains @ 2023-11-07 12:47:35

你或许需要写一个高精度。


by 11ofjay @ 2023-11-07 12:47:40

print(reduce(lambda x,y:x+y,[reduce(lambda x,y:x*y,range(1,i+1)) for i in range(1, int(raw_input())+1)]))

by OIerGuo @ 2023-11-07 13:18:20

@xxJoy0420 高精,看数据范围


by xxJoy0420 @ 2023-11-07 13:22:36

@OIerGuo 谢谢大佬!


|