dingding2008 @ 2023-05-13 22:07:44
#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int a[N], b[N];
int len = 1, len2 = 1;
inline void add()
{
}
inline int mul(int x[], int y)
{
for (int i = 1; i <= len; i++)
{
x[i] *= y;
}
for (int i = 1; i < len; i++)
{
x[i+1] += x[i] / 10;
x[i] %= 10;
}
while (x[len] >= 10)
{
x[len+1] += x[len] / 10;
x[len] %= 10;
len++;
}
return len;
}
int main()
{
int n;
scanf("%d", &n);
b[1] = 1;
for (int i = 1; i <= n; i++)
{
mul(b, i);
add();
}
for (int i = len2; i >= 1; i--)
{
printf("%d", a[i]);
}
return 0;
}
dalao们,谁能告诉我add函数怎么写啊...
如果帮我AC了,我就可以关注你.
本萌新太垃圾了(我才四年级)
by 2011Andy @ 2023-05-13 22:12:25
考虑python(bushi
n = int(input());
jie = 1;
sum = 0;
i = 1;
while n >= i:
jie = jie * i;
sum = sum + jie;
i = i + 1;
print(sum);
by dingding2008 @ 2023-05-13 22:13:51
哇!太及时了,我刚好在,但我不会python...
by 2011Andy @ 2023-05-13 22:17:06
void change(int x)
{
int g=0;
for(int i=100;i>=0;i--)
{
a[i]=a[i]*x+g;
g=a[i]/10;
a[i]=a[i]%10;
}
}
void qh()
{
int g=0;
for(int i=100;i>=0;i--)
{
s[i]=s[i]+a[i]+g;
g=s[i]/10;
s[i]=s[i]%10;
}
}
上面是乘 下面是加 可以分成2个函数来写
by dingding2008 @ 2023-05-14 10:00:34
已关注
by dingding2008 @ 2023-05-17 19:02:27
@2011Andy 看到了嘛?
by 2011Andy @ 2023-05-17 19:19:27
看到了thank you
QAQ
by 宇宙风景 @ 2023-05-29 12:29:12
洛谷WA中说求助,听取WA声一片……
by l3jE75oDM1k9 @ 2023-05-30 18:55:24
我也四年级
by dingding2008 @ 2023-06-02 22:04:33
哈哈
by 5735733ckl @ 2023-07-05 21:56:27
唉嘿,都不容易,这个号也是我四年级建的,现在我初一,正式学编程了,加油ヾ(◍°∇°◍)ノ゙