<Problem>
http://ntucoder.net/Problem/Details/3341
Uses Crt;
Var str:array[0..1000] of ansistring;
digit_1,digit_2:ansistring;
chr:char;
n,i,j,count,remain:longint;
Begin
readln(n);
str[0]:='0';
for i:=1 to n do
begin
str[i]:=''; digit_1:=''; digit_2:='';
remain:=0;
for chr:=str[i-1][1] to '9' do
if pos(chr,str[i-1])=0 then
begin
digit_1:=chr;
break;
end;
if digit_1='' then
begin
for chr:='1' to '9' do
if pos(chr,str[i-1])=0 then
begin
digit_1:=chr;
break;
end;
remain:=remain+1;
end;
remain:=remain+length(str[i-1])-1;
for chr:='0' to '9' do
if pos(chr,str[i-1])=0 then
begin
for j:=1 to remain do digit_2:=digit_2+chr;
break;
end;
str[i]:=digit_1+digit_2;
//writeln(str[i]);
end;
writeln(str[n]);
readln;
End.
(*Nhan xet
Cac so chi co 2 chu so
Co 2 van de la tim chu so dau tien va cac chu so dang sau deu giong nhau
De tim chu so dau tien thi co hai truong hop: truong hop do dai cac so la bang nhau va truong hop do
dai cac so phai cong 1
*)