CZH_xixi @ 2024-05-26 09:28:41
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,sum=0;
int main(){
cin>>a;
b=a;
c=a;
d=a;
while(b>1)
{
a*=b-1;
b-=1;
}
sum+=a;
for(int i=c;i>=0;i--)
{
sum+=a/c;
a/=c;
c-=1;
}
cout<<sum;
}
在c++Dev测试时一直崩溃,主要是在标记处,求!
by incra @ 2024-05-26 09:32:31
@2023_1202 sum+=a/c;
这一句 c 会等于 0
by CZH_xixi @ 2024-05-26 09:33:37
@incra 谢谢!
by CZH_xixi @ 2024-05-26 09:34:32
@incra 可以问一下为什么吗
by cabbage_flower @ 2024-05-26 09:38:39
@2023_1202 因为你每次c-=1,所以你的c可能会减到0
by CZH_xixi @ 2024-05-26 09:42:39
@cabbage_flower 谢谢!懂啦
by cabbage_flower @ 2024-05-26 09:44:02
@2023_1202 关注一下呗
by CZH_xixi @ 2024-05-26 09:47:22
@cabbage_flower 来啦!
by CZH_xixi @ 2024-05-26 09:48:34
@cabbage_flower 全r了(不开心了~)差了5是什么原因啊
by CZH_xixi @ 2024-05-26 09:49:59
@2023_1202 输入为6的情况下
by cabbage_flower @ 2024-05-26 09:51:55
@2023_1202 你会高精度吗,这题需要高精度