You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
//高精度乘法模板
vector<int> mul(vector<int> &A, int b) {
vector<int> C;
int t = 0;
for (int i = 0; i < A.size() || t; i++) {
if (i < A.size()) t += A[i] * b;
C.push_back(t % 10);
t /= 10;
}
while (C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
int n, num;
int ans;
vector<int> C;
int main() {
cin >> n;
//无脑的增大序列
for (num = 2; ans + num <= n; num++) {
ans += num;
C.push_back(num);
}
//余数
int r = n - ans;
//后面的人,每人一个,如果一轮没有分完,就继续再来一轮
//举栗子13
// 2 3 4 余数 4
// 最终分配结果 3 4 6
while (r) {
for (int i = C.size() - 1; i >= 0 && r; i--) {
C[i] += 1;
r--;
}
}
//输出C
for (int i = 0; i < C.size(); i++) printf("%d ", C[i]);
printf("\n");
//下面是高精度乘法
vector<int> A;
A.push_back(1);
for (int i = 0; i < C.size(); i++) A = mul(A, C[i]);
//倒着输出
for (int i = A.size() - 1; i >= 0; i--) printf("%d", A[i]);
return 0;
}