- 题面
- 题意:给出一个数
a
1
\small a_1
a1与构造次数
k
\small k
k,需要对
a
1
\small a_1
a1操作
k
\small k
k次,输出构造后的数
a
k
\small a_k
ak。
操作过程见图解:
- 解决思路:当有一位的数为
0
\small 0
0时,其实后面的数都一样了,就可以跳出循环了。
- AC代码
#pragma GCC optimize(2)
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<istream>
#include<iomanip>
#include<climits>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define N 2010
#define DoIdo main
#define it set<ll>::iterator
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int maxn = 10 + 10;
using namespace std;
ll max(ll a, ll b) { return a > b ? a : b; }
ll min(ll a, ll b) { return a < b ? a : b; }
ll get(ll x) {
ll mi = 11, mx = 0;
while (x) {
ll t = x % 10;
mi = min(mi, t);
mx = max(mx, t);
x /= 10;
}
return mi * mx;
}
int DoIdo() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
ll T;
cin >> T;
while (T--) {
ll a1, k;
cin >> a1 >> k;
k--;
while (k--) {
ll val = get(a1);
if (!val) break;
a1 += val;
}
cout << a1 << endl;
}
return 0;
}