# include # include # include using namespace std; const int Max = 100001; char str[Max]; int main() { int N, n, i, j, k, count, len, remainder, index, shang, remainder_1; scanf("%d", &N); k = 1; while(N--){ getchar(); gets(str); scanf("%d", &n); len = strlen(str); shang = len / n; remainder = len % n; //大循环是行数 count = 0; printf("Case #%d:\n", k++); for(i = 0; i < (remainder > 0 ? (shang+1) : shang); i++){ index = i; remainder_1 = remainder; for(j = 0; j < n; j++){ if(count >= len) break; printf("%c", str[index]); count++; if(remainder_1 > 0){ index += shang + 1; remainder_1--; }else index += shang; } } printf("\n"); } return 0; }