75分求助
查看原帖
75分求助
742628
I_AK_Ynoi楼主2022/7/9 11:59
#include <bits/stdc++.h>
using namespace std;
namespace IO{
    inline __int128 read(){
		register __int128 x = 0,f = 1;
		register char ch = getchar();
		while(ch<'0'||ch>'9'){
			if(ch=='-'){
				f = -1;
			}
			ch = getchar();
		}
		while(ch>='0'&&ch<='9'){
			x = x * 10 + ch - '0';
			ch = getchar();
		}
		return x*f;
	}
	inline void write(__int128 x){
		if(x<0){
			putchar('-');
			x = -x;
		}
		register int n = 0;
		char s[100];
		while(x||!n){
			s[n++] = '0' + x % 10;
			x /= 10;
		}
		while(n--){
			putchar(s[n]);
		}
		return;
	}
}
using namespace IO;
int main(){
	__int128 a[1000], b = 0, n;
	n = read();
	a[1] = 1;
	for(int i=2;i<=n+1;i++){
		a[i] = a[i-1] * i;
	}
	for(int i=1;i<=n;i++){
		b = b + a[i];
	}
	write(b);
	return 0;
}
2022/7/9 11:59
加载中...