//土尔逊Torson 编写于2023/05/27 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <string> #include <cstring> using namespace std; const int MAXN = 10000; struct BigInteger08401 { int digit[MAXN]; int length; BigInteger08401(); BigInteger08401(int x); BigInteger08401 operator=(string str); BigInteger08401 operator+(const BigInteger08401& b); BigInteger08401 operator*(const BigInteger08401& b); friend istream& operator>>(istream& in, BigInteger08401& x); friend ostream& operator<<(ostream& out, const BigInteger08401& x); }; istream& operator>>(istream& in, BigInteger08401& x) { string str; in >> str; x = str; return in; } ostream& operator<<(ostream& out, const BigInteger08401& x) { for (int i = x.length - 1; i >= 0; --i) { out << x.digit[i]; } return out; } BigInteger08401::BigInteger08401() { memset(digit, 0, sizeof(digit)); length = 0; } BigInteger08401::BigInteger08401(int x) { memset(digit, 0, sizeof(digit)); length = 0; if (x == 0) { digit[length++] = x; } while (x != 0) { digit[length++] = x % 10; x /= 10; } } BigInteger08401 BigInteger08401::operator=(string str) { memset(digit, 0, sizeof(digit)); length = str.size(); for (int i = 0; i < length; ++i) { digit[i] = str[length - i - 1] - '0'; } return *this; } BigInteger08401 BigInteger08401::operator+(const BigInteger08401& b) { BigInteger08401 answer; int carry = 0; for (int i = 0; i < length || i < b.length; ++i) { int current = carry + digit[i] + b.digit[i]; carry = current / 10; answer.digit[answer.length++] = current % 10; } if (carry != 0) { answer.digit[answer.length++] = carry; } return answer; } BigInteger08401 BigInteger08401::operator*(const BigInteger08401& b) { BigInteger08401 answer; answer.length = length + b.length; for (int i = 0; i < length; ++i) { for (int j = 0; j < b.length; ++j) { answer.digit[i + j] += digit[i] * b.digit[j]; } } for (int i = 0; i < answer.length; ++i) { answer.digit[i + 1] += answer.digit[i] / 10; answer.digit[i] %= 10; } while (answer.digit[answer.length - 1] == 0 && answer.length > 1) { answer.length--; } return answer; } int main() { int a, n; while (scanf("%d%d", &a, &n) != EOF) { BigInteger08401 Q(a); BigInteger08401 answer(0); for (int i = 1; i <= n; ++i) { for (int j = 1; j < i; ++j) { Q.digit[j] = a; Q.length++; } answer = answer + Q; Q = a; } cout << answer << endl; } system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")