51nod 1057 N的阶乘(大数-划分)
发布时间:2021-01-16 08:25:59 所属栏目:大数据 来源:网络整理
导读:51nod 1057 N的阶乘(大数-划分) 实话说,题目我做过,但是再次写到这道题目的时候,我就不再想起用这样的方法。所以,我认为记录下来是很有必要的, 1.可以强化理解 2.可以回顾 这道题目,用大数乘法做太过繁琐。划分其实是将答案划分成可以输出的数据,再
51nod 1057 N的阶乘(大数-划分) 实话说,题目我做过,但是再次写到这道题目的时候,我就不再想起用这样的方法。所以,我认为记录下来是很有必要的, 这道题目,用大数乘法做太过繁琐。划分其实是将答案划分成可以输出的数据,再以格式化输出。 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> #include <map> using namespace std; #define LL long long #define INF 0x3f3f3f3f #define PI acos(-1.0) #define E 2.71828 #define MOD 100000000 #define N 11000 LL a[N]; int main() { int n; scanf("%d",&n); a[0] = 1; int m = 1; for(int i = 1; i <= n; i++) { LL t = 0;//printf("sdfs"); for(int j = 0; j < m; j++) { LL x = a[j]*i+t; t = x / MOD; a[j] = x % MOD; } if(t > 0) //jin wei a[m++] = t; } printf("%lld",a[m-1]); for(int i = m-2; i >= 0; i--) printf("%0.8lld",a[i]); printf("n"); return 0; } (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读