Blue Bridge Cup previous-strange series
Not to review the algorithm, estimating the country will kneel ...
Title: Strange series Intercept a code from Planet X, which is some number, as follows: -111331131321131113122113.... Dr. Yy through the night study, found the law: the first line of the number of whatever, after each row is the last line "read out" for example2Yes, it's the first.1A description of the line, meaning:1A1,1A3, so it is:1113The3Yes, it means:3A1,1A3, so it is:3113Ask you to write a program that can start with the initial numbers and make such transformations continuously. Data format: The first line enters a string consisting of a number, no more than -Bit second line, a number n, indicates how many times you need to transform, n does not exceed -Outputs a string that represents the result of the last transformation. For example: User output:57The program should output:13211321322115Resource contract: Peak memory consumption (with virtual machine) < 512MCPU consumption < 1000ms please output in strict accordance with the requirements, do not use the superfluous printing like: "Please enter..."The extra content. All the code is placed in the same source file, after debugging passed, the copy is submitted to the source. Note: Do not use the package statement. Do not use jdk1.7 and the features of the above version. Note: The name of the main class must be: main, otherwise it will be treated as invalid code.
This is the fourth question of the national game, that is, the first way of programming, not difficult. Water over:
#include <cstdio>#include <iostream>#include <algorithm>#include <cstring>using namespace STD;structmode {intSum, p;};intN, M, s2[10000];Chars1[10000];mode GetMode (intStart) {mode M1;intI, sum =1; for(i = start; S1[i] = = s1[i+1]; i++) {sum++; } m1.sum = sum; M1.P = i+1;returnM1;}intMain () {Freopen ("In.txt","R", stdin);scanf("%d%d", &n, &m);intK =0;sprintf*SS,"%d"+ i); while(m--) {intLen =strlen(S1); K =0; for(inti =0; i < Len;) {intt = s1[i]-' 0 '; Mode M1 = GetMode (i); i = M1.P; s2[k++] = m1.sum; s2[k++] = t; }memset(S1,0,sizeof(s1)); for(inti =0; I < K; i++) S1[i] = s2[i]+' 0 '; } for(intj =0; J < K; J + +)printf("%d", S2[j]);return 0;}
Blue Bridge Cup previous-strange series