P1009 [NOIP1998 普及组] 阶乘之和 50pts

P1009 [NOIP1998 普及组] 阶乘之和

禹天钧2016 @ 2024-04-30 17:40:28

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

??? 必关!!!


by aleavf @ 2024-05-13 10:29:18

@禹天钧2016 可以用python,python自带高精度


by 禹天钧2016 @ 2024-05-13 19:50:37

@aleavf python我不会


by aleavf @ 2024-05-21 19:07:51

a=int(input())
s=0
b=1
for i in range(a):
   b=b*(i+1)
   s+=b
print(s)

@禹天钧2016


by 禹天钧2016 @ 2024-05-23 19:33:07

答案………………………………………………


上一页 |