2AC , 2WA

P1009 [NOIP1998 普及组] 阶乘之和

99999873654as7829 @ 2023-10-18 09:51:13

求求大佬相助```cpp #include<iostream> using namespace std; int jc(long long a){ if (a==1){ return 1; } return a*jc(a-1); } int jc2(long long a){ long long s=0; for (int i=1;i<=a;i++){ s+=jc(i); } return s; } int main(){ long a; cin>>a; long long b=jc2(a); cout<<b; }


by hytallenxu @ 2023-10-18 10:07:42

这题高精度,会爆long long


by 99999873654as7829 @ 2023-10-18 10:19:24

@hytallenxu 听不懂,详细一点好吗?


by loose @ 2023-10-19 11:09:06

@wuyuhang2012 我也是这么想的,但是50!远远大于计算机能表示的数,这道题需要用到高精度,你可以搜索一下


by 99999873654as7829 @ 2023-10-20 22:20:18

@loose 我用了long long


by xzwdqjdx @ 2023-10-21 09:54:36

可以试一试 long double或者int_128


by 99999873654as7829 @ 2023-10-21 13:09:34

@xzwdqjdx 谢谢


by 99999873654as7829 @ 2023-10-24 22:47:30

发一下代码


|