Files
python/TangDou/Mkx/202412C1/8703.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

44 lines
928 B
C++

#include <bits/stdc++.h>
using namespace std;
// 高精度乘法
const int N = 1e5 + 10;
int a[N], al;
void mul(int a[], int &al, int b) {
int t = 0;
for (int i = 1; i <= al; i++) {
t += a[i] * b;
a[i] = t % 10;
t /= 10;
}
while (t) {
a[++al] = t % 10;
t /= 10;
}
// 去前导0
while (al > 1 && !a[al]) al--;
}
// 判断一个数是不是质数
bool isPrime(int n) {
if (n < 2) return false;
for (int i = 2; i <= n / i; i++)
if (n % i == 0) return false;
return true;
}
int main() {
int n;
cin >> n;
// 初始化
a[++al] = 1;
// 阶乘
for (int i = 1; i <= n; i++) mul(a, al, i);
int sum = 0;
// for (int i = al; i; i--) printf("%d", a[i]);
for (int i = al; i; i--) sum += a[i];
cout << sum << " " << (isPrime(sum) ? "T" : "F") << endl;
return 0;
}