包对

取名不要太长,像我这样刚刚好  •  3个月前


include <bits/stdc++.h>

using namespace std; int a[120], b[120] ;

void add(int a, int b) {

int jw = 0;
for (int i = 1; i <= 120; i++) {
	b[i] = b[i] + a[i] + jw;
	jw = b[i] / 10;
	b[i] = b[i] % 10;
}

}

void cheng(int *a, int c) {

int jw = 0;
for (int i = 1; i <= 120; i++) {
	a[i] = a[i] * c + jw;
	jw = a[i] / 10;
	a[i] = a[i] % 10;
}

}

int main() {

memset(b, 0, sizeof(b));
memset(a, 0, sizeof(a));
int n;
cin >> n;
a[1] = 1;
for (int i = 1; i <= n; i++) {
	cheng(a, i);
	add(a, b);
}
int flag = 0;
for (int i = 120; i >= 1; i--) {
	if (b[i] != 0) {
		flag = i;
		break;
	}
}
for (int i = flag; i >= 1; i--) {
	cout << b[i];
}
return 0;

}


评论:

请先登录,才能进行评论