Similar to d in the Xi'an Invitational Competition
This question will pop up the stack, so non-recursive writing is required. However, after reading this question for a long time, the Code is not understood and will be rewritten later.
Question: http://blog.csdn.net/dongshimou/article/details/37815377
Http://www.cnblogs.com/372465774y/p/3200775.html
# Include <cstdio> # include <cmath> # include <iostream> using namespace STD; const int size = 100000 + 10; int A, s; int sta [size * 10], li [size * 10]; char ans [size * 10]; void sea (int v, int m) {int W; while (Li [v] <10) {W = V * 10 + Li [v]; // It is equivalent to moving one digit left, that is, the last n-1 bits of the previous number move one to the left as the first n-1 bits of the second number Li [v] ++; // The range of Li [v] is 0-9 ,, it is the V bit. Try it and make sure that it has not appeared before, because the last line of Li [v] has been used, therefore, try Li [v] + 1 sta [s ++] = W; // The answer is stored in the STA. Note that 0 indicates n-1 0 V = w % m; // shift "overflow"} int main () {int N, M; while (~ Scanf ("% d", & N) {If (n = 1) {printf ("0123456789 \ n"); continue;} int V = 0; S = A = 0; M = POW (10.0, double (n-1); For (INT I = 0; I <m; I ++) Li [I] = 0; sea (v, m); While (s) {v = sta [-- S]; ans [A ++] = V % 10 + '0'; V/= 10; sea (v, m) ;}for (INT I = 1; I <n; I ++) putchar ('0'); While () putchar (ANS [-- A]); putchar ('\ n');} return 0 ;}
Poj 1780 Euler Loop construction string