首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
彻底死去
2026年3月19日 19:48
阶乘和 题解:
P1044
回复 0
|
赞 0
|
浏览 87
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string> #include<cstring> using namespace std; int main() { int n; long long int a = 0; cin >> n; for (int i = 1; i <= n; i++) { lo...
yauqq
2026年3月18日 19:37
阶乘和 题解:
P1044
回复 0
|
赞 0
|
浏览 81
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll fac(ll n){ if (n <= 0) return 1; else return n * fac(n - 1); } int main(){ int n; cin >> n; ll sn = 0; for(int i=1;i<=n;i++) sn += fac(i); cout << sn << endl;...
太一
2026年3月18日 17:15
阶乘和 题解:
P1044
回复 0
|
赞 1
|
浏览 77
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<map> using namespace std; long long sum(int n) { if (n == 1) { return 1; } return n * sum(n - 1); } int main() { int n; long long num = 0; ...
HKX9XAS
2026年3月5日 22:10
阶乘和 题解:
P1044
回复 0
|
赞 2
|
浏览 165
/* 无循环双递归实现 */ #include<stdio.h> #include<iostream> using namespace std; long long JC(long long n){ //得到一个数的阶乘值 if(n==0) return 1; return n*JC(n-1); } long long Sn(long long n){ ...
mlx
2026年2月9日 11:02
阶乘和 题解:
P1044
回复 0
|
赞 2
|
浏览 258
#include<iostream> using namespace std; const int N=21; typedef long long ll; int n; ll fact[N]; int main() { fact[0]=1; for(int i=1;i<=N;i++) fact[i]=i*fact[i-1]; cin>>n; ll res=0; for(int i=1;i<=n;i++) res+=fact[i]; cout<<res; retur...
xsw
2026年2月6日 12:26
阶乘和 题解:
P1044
回复 0
|
赞 1
|
浏览 224
#include<iostream> #include<algorithm> using namespace std; typedef long long LL; LL cal(int x) { if (x == 1) return x; return x * cal(x - 1); } int main() { int n; cin >> n; LL sum = 0; for (int i = 1; i <= n; i ++ ) sum += cal(i); ...
yauqq
2026年1月28日 16:49
阶乘和 题解:
P1044
回复 0
|
赞 0
|
浏览 243
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; long long ans = 0; for(int i = 1; i <= n; i++){ long long k = 1; for(int j = i; j >= 1; j--){ k *= j; } ans += k; } cout << ans << endl;...
bro
2026年1月20日 13:33
阶乘和 题解:c++ ,最普通的递归,比较容易理解
P1044
回复 0
|
赞 3
|
浏览 270
#include <bits/stdc++.h> using namespace std; long long number(long long n){ if(n == 1) return 1; return number(n-1)*n; } int main() { int n ; cin >> n; long long sum = 0; &...
jerryking
2026年1月9日 15:59
阶乘和 题解:迭代法
P1044
回复 0
|
赞 3
|
浏览 336
#include<stdio.h> int main(){ int n; scanf("%d",&n); long fac[n+1]; //根据题目描述,可能超过int范围,故使用long保存最终结果 long Sn=0; fac[0]=1; ...
波耶菠萝蜜
2025年7月26日 16:55
阶乘和 题解:
P1044
回复 0
|
赞 3
|
浏览 1.0k
考的就是递归或者迭代,还不错 // 求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字。 // 输入一个n(n<=20) #include <stdio.h> long int f(long int n); int main(){ long int n =0;//承接输入 long int a=0;//output scanf("%ld",&n); for...
1
2
3
题目
阶乘和
题解数量
27
发布题解
在线答疑
热门题解
1
阶乘和 题解:关键代码只需三行
2
阶乘和 题解:纯C
3
阶乘和 题解(小白超易懂,循环做法或者递归):
4
阶乘和 题解:简单暴力
5
阶乘求和
6
阶乘和 题解:考虑到数据的容量,使用longlong改写n!即可
7
阶乘和 题解:迭代法
8
阶乘和 题解:
9
阶乘和 题解:c++ ,最普通的递归,比较容易理解
10
阶乘和 题解:直接算吧