), So determine whether 19u is the number of duplicates (by simply judging whether 19u's single digit and ten digits are the same .).
), So the problem is to calculate the no-duplicated plural () of 2010u ().
).
#include <stdio.h> main( ( i = ; i < + ; i++ printf ( , i , find( i + printf( , n ) ; ( n < ( n / < ( t = find( n / n = t * ( n % == n / % find( n + }
# Include <stdio. h> typedef struct {unsigned char t [20]; // This space should be enough int top; // record the first subscript} Map; unsigned find (unsigned ); void parse (Map *, unsigned); int search (const Map *); void add_1 (Map *, const int); void clear (Map *, const int, const int ); unsigned combi (const Map *); int main (void) {unsigned iu; // test for (iu = 19922884u; iu <19922884u + 1u; iu ++) {printf ("% u \ n", iu, find (iu + 1u);} return 0;} unsigned combi (const Map * p_m) {unsigned nu = 0u; int I; for (I = p_m-> top; I> = 0; I --) {nu * = 10u; nu + = p_m-> t [I];} return nu;} void clear (Map * p_m, const int from, const int to) {int I; for (I = from-1; I> to-1; I --) p_m-> t [I] = 0u;} void add_1 (Map * p_m, const int from) {int I; p_m-> t [from] ++; // The Vertex plus 1 for (I = from; I <p_m-> top; I ++) // carry processing {p_m-> t [I + 1] + = p_m-> t [I]/10u; p_m-> t [I] % = 10u ;} if (p_m-> t [p_m-> top]> 9u) // The highest bit has a forward position {p_m-> t [p_m-> top + 1] = p_m-> t [p_m-> top]/10u; p_m-> t [p_m-> top ++] % = 10u ;}} int search (const Map * p_m) {int I; for (I = p_m-> top; i> 0; I --) {if (p_m-> t [I] = p_m-> t [I-1]) break;} return I-1 ;} void parse (Map * p_m, unsigned n) {p_m-> top =-1; while (n> 0u) {p_m-> t [++ p_m-> top] = n % 10u; n/= 10u ;}} unsigned find (unsigned n) {Map map; int end = 0, B _point; parse (& map, n); // splits n into numbers while (B _point = search (& map)>-1) // when the value is-1, it indicates that the number of duplicates is not {add_1 (& map, B _point); // Add 1 clear (& map, B _point, end) to the number of duplicates ); // change the value to 0 end = B _point later. // determine the processing range of the next loop.} return combi (& map );}
0 0 2