- #include <iostream>
- #include <string>
- #include <cstring>
- #include <string.h>
- #include <cstdio>
- #include <stdio.h>
- #include <stdlib.h>
- #include <cstdlib>
- #include <algorithm>
- #include <math.h>
- using namespace std;
- int main() {
- //freopen("in.txt", "r", stdin);
- int n;
- scanf("%d", &n);
- while(n--) {
- string num, num2; int k, g;
- cin >> num >> k;
- printf("%s\n", num.c_str());
- while(k--) {
- g = 0;
- int size = num.size();
- for (int i = 0; i < size; i++) {
- int cont = 1; char tmp = num[i];
- while(num[i] == num[i+1] && i < size) i++, cont++;
- printf("%d%c", cont, tmp);
- num2.push_back(cont+'0');
- num2.push_back(tmp);
- }
- num = num2;
- num2.clear();
- printf("\n");
- }
- printf("\n");
- }
- return 0;
- }
Raw Paste