#Description
原题
#Algorithm
以159263748为例
0 0+4 0+2*4
1 1+4
2 2+4
3 3+4
这样很容易就找的模拟的办法了
一个一个填过去就好了
关键是这题卡C++ 连getline都会TLE
只能用gets和字符数组
不能用字符串类
#Code
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAX_L = 1e5 + 9;
char s[MAX_L];
char ans[MAX_L];
void solve()
{
gets(s);
int l = strlen(s);
int x;
scanf("%d\n", &x);
memset(ans, 0, sizeof(ans));
int t = l / x;
if (l % x != 0) t++;
int a = 0;
int b = 0;
for (int i = 0; i < l; i++) {
ans[a + b * x] = s[i];
b++;
if (a + (b - 1) * x == l - 1) {
t--;
a++;
b = 0;
continue;
}
if (b == t) {
a++;
b = 0;
}
}
printf("%s\n", ans);
}
int main()
{
// freopen("input.txt", "r", stdin);
int t;
scanf("%d\n", &t);
for (int i = 1; i <= t; i++) {
printf("Case #%d:\n", i);
solve();
}
}