Problem A - Sequence with Digits (数学推导)
题意:
已知 \(a_1\) 求 \(a_k\) ,推导公式见题面。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, _, a;
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--) {
cin >> n >> k;
k--;
while (k--) {
a = n;
ll l = 10, r = 0;
while (a) {
l = min(l, a % 10);
r = max(r, a % 10);
a /= 10;
}
if (!l)break;//如果存在前导0直接break
n += l * r;
}
cout << n << endl;
}
}