Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function f(start, current: integer): integer;
- begin
- if current = start then result:=1 else
- if current < start then result:=0 else
- begin
- result:=f(start, current - 1);
- result +=f(start, current - 3);
- if (current = 5) or (current=10) then result:=0;
- if current.divs(2) then result +=f(start, current div 2);
- end;
- end;
- begin
- print(f(2,14)*f(14,20))
- end.
- ------------------------------------------------------------------------------------
- ### function f(a,b: int):int:=
- a<b or (a in |8,11|) ?0 : a=b ? 1 : f(a-8,b) + f(a div 2,b) + f(a.Digits.Agr(0,(a,d)->a*10+(d<9?d+1:d))
- print(f(102,43)*f(43,5));//вычитание, не содержит 8 и 11, увеличение по разрядам, если меньше 9.
- --------------------------------------------------------------------------------------
- //1. Умножь на 8
- //2. Подели на 3
- //Сколько чисел можно получить из 729 за 6 ходов
- ###
- function f(a,n:int; var hs: HashSet<integer>):int;
- begin
- if n=6 then
- begin
- hs.Add(a);
- end
- else
- begin
- f(a*8,n+1,hs);
- if a mod 3 = 0 then f(a div 3,n+1,hs);
- end;
- end;
- var l:= new HashSet<integer>;
- f(729,0,l);
- l.pr;
Add Comment
Please, Sign In to add comment