半个小时看懂了大佬写的10行代码
#include#include #include using namespace std;const int maxn = 40000;int f[40000];int n;int main(){ while(scanf("%d",&n)!=EOF) { memset(f,0,sizeof(f)); f[0] = 1; for(int i = 2; i <= n; i++) { int c = 0;//低位来的进位 for(int j = 0; j < maxn; j++) { int s = f[j]*i+c; f[j] = s%10; c = s/10; } } int flag = 0; for(int i = maxn-1; i >= 0; i--) { if(f[i]!=0) { flag = i; break; } } for(int j = flag; j >= 0; j--) printf("%d",f[j]); printf("\n"); } return 0;}