首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
yb5942
2025年3月23日 23:48
阶乘和 题解:简单暴力
P1044
回复 0
|
赞 3
|
浏览 120
#include <iostream> using namespace std; long long jiechen(int n) { if (n == 0 || n == 1) return 1; //0!=1 return n * jiechen(n - 1); } int main() { int n; cin >> n; &n...
阿灿
2025年3月15日 06:35
阶乘和 题解:直接算吧
P1044
回复 0
|
赞 1
|
浏览 151
#include<bits/stdc++.h> using namespace std; long long n[22]={1}; long long sn[22]={0}; int main(){ int i,num; for(i=1;i<=20;i++){ n[i] = n[i-1]*i; sn[i] = sn[i-1]+n[i]; } cin>>num; cout<<sn[num]<<endl; return 0; }
zxjrheaven
2025年3月14日 14:57
阶乘和 题解:暴力
P1044
回复 0
|
赞 1
|
浏览 99
#include <bits/stdc++.h> using namespace std; long long qiu(long long n) { if(n==1)return 1; else return n*qiu(n-1); } int main() { long long n; long long sum=0; cin>>n; &nbs...
16696033405
2025年3月9日 12:02
阶乘和 题解:关键代码只需三行
P1044
回复 0
|
赞 8
|
浏览 240
#include<stdio.h> int main(){ int N; long int sum=0,m=1; scanf("%d",&N); for(int i=1;i<=N;i++){ m=m*i;  ...
chenshoumin
2025年2月6日 09:49
阶乘和 题解:纯C
P1044
回复 0
|
赞 6
|
浏览 353
#include <stdio.h> long long factorial(int n){ long long fac=1; for(long long i=n; i>=1; i--){ fac*=i; } return fac; } long long getF(long long a){ if(a==0||a==1)return 1; ...
致敬大佬
2024年8月2日 23:42
阶乘和 题解(小白超易懂,循环做法或者递归):
P1044
回复 0
|
赞 5
|
浏览 810
从y总的求组合数来的,到这道题几乎降维打击 #### 循环做 #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const int N = 20; LL fact[N]; int main() { int n; cin >> n; fact[0] = 1; int res = 0; for (int i = 1; i <= n; i ++)...
Candour
2024年5月8日 00:31
阶乘和(优雅的递归) 题解:
P1044
回复 0
|
赞 2
|
浏览 638
注意数据范围,递归函数里的x也会爆int #include <bits/stdc++.h> using namespace std; typedef long long LL; int n; LL ans; LL dfs(LL x) { if(x == 1) return x; x = x * dfs(x - 1); } int main() { cin >> n; for(int i = 1; i <= n; i ++) ans += dfs(i); cou...
RingoCrystal
2024年4月6日 11:21
阶乘和 题解:考虑到数据的容量,使用longlong改写n!即可
P1044
回复 0
|
赞 4
|
浏览 743
#include <stdio.h> long long getF(long long a){ if(a==0||a==1)return 1; return a*getF(a-1); } int main(){ int n; scanf("%d",&n); long long ans=0; for(int i=1;i<=n;i++){ ans+=getF(i); } printf("%lld\n",ans); return 0; }
Cookie‘s AE86
2024年3月20日 20:45
阶乘和 题解:C++ 一个for循环,14行代码解决
P1044
回复 0
|
赞 0
|
浏览 1.4k
#include<bits/stdc++.h> using namespace std; int main(){ long long n; long long sn = 0; long long tmp = 1; cin >> n; for(int i = 1; i <= n; i++){ tmp *= i; sn += tmp; } cout << sn; return 0; }
小王桐学
2024年2月7日 21:13
阶乘和 题解:C
P1044
回复 0
|
赞 0
|
浏览 846
#include <stdio.h> long long Factorial(int n) { long long s =1; int i; while(n) { s*=n; n--; } return s; } int main() { int n,i; long long Sn = 0; scanf("%d",&n); for(i = 1; i <= n; i++) Sn+=Factorial(i); printf("%lld\n",Sn); return 0; } ...
1
2
题目
阶乘和
题解数量
17
发布题解
在线答疑
热门题解
1
阶乘和 题解:关键代码只需三行
2
阶乘和 题解:纯C
3
阶乘和 题解(小白超易懂,循环做法或者递归):
4
阶乘和 题解:考虑到数据的容量,使用longlong改写n!即可
5
阶乘求和
6
阶乘和 题解:简单暴力
7
阶乘和(优雅的递归) 题解:
8
阶乘求和(大数相乘思想)
9
Accepted答案-阶乘加和(C)-(函数解法)
10
阶乘和 题解:暴力