[[English Page]]~
[[Elementary Techniques]] | [[Techniques of Function]] | [[Techniques of Recursion]] |Techniques of Number

#contents

*Recycle numerical functions [#edf4048e]
**Sample Code 1 [#yf226cd3]
 a(X,T):XXa(sX,T-1)XX
 a(a(,3)a(r,9)r,1)

**Sample Code 2 [#fcf3eb07]
 a(X,T):a(sX,T-1)XX
 a(ra(r,6),100)

*IF statement [#i204bb42]
**Sample Code 1[#u01684dc]
 a(T):rsrrsr
 b(T):a(2-T)b(T-5)
 c(T):b(T)sc(T-1)
 c(20)

In this code, b(T) equals "rsrrsr" if T≡1 mod 5, and no moves otherwise. 

**Examples [#p8f6fdb5]
-[[Problem 0248]]
-[[Problem 0225]]


*Rational Growth [#o3f31f90]
**Sample Code [#u01684dc]
 a(T):sa(T-5)
 b(T):a(T)rb(T+7)
 b(1)

The speed of growth is "7/5". 

**Examples [#p8f6fdb5]

*12B method [#c43b9803]
**Sample Code [#u01684dc]
 f(T):sf(T-4)rf(T+7)
 f(8)

This code realizes the loop
 a:ssrsssrsssrsssra
 a

In this loop, the number of "s" equals 4 + 7, and the number of "r" equals 7.~
In generally, the code
 f(T):[1]f(T-A)[2]f(T+B)
implies a loop with (A+B) times of "[1]" and B times of "[2]".

**Sample Code 2 [#yf2cc31b]
 a(T):sa(T-37)ra(T+83)
 a(1)
Since 83/37 approximately equals 9/4, this code is similar to 
 a(T):sa(T-4)ra(T+9)
 a(1)
but the small difference changes the direction of the movement. ~
Therefore, "square minus square" shape can be drawn by a 12B code. 

**Sample Code 3 [#b0833cb0]
 f(T):sf(T-15)rf(T+T+63)
 f(1)
Some new sequence can be obtained by changing the coefficient of degree = 1.~
In this case, the periodic sequence
> 1,[5,5,6,7],[5,5,6,7],[5,5,6,7],...
appear. 

appears. 

**Examples [#p8f6fdb5]
-[[Problem 0599]]
-[[Problem 0996]]

*Random walk by a numerical function [#q769cd56]
**Sample Code [#wa54fc27]
 f(T):sf(T-4)rf(T-7)
 f(255)

**Examples [#uce7bcab]
Probably, no problems in HOJ requires this method (even for "best solution") at this moment.

*Compress long statement by numbers [#q4fe1726]
**Sample Code 1 [#f075df6b]
 a(T,A):ra(T-A,A)
 f(T):a(T,64)sa(T,16)sa(T,4)sa(T,1)s

By f(1 to 255), you can make all patterns of four step move, except "ssss". 

**Sample Code 2 [#f4f28421]
 a(T,X):X
 b(A,B,X):b(A-127,B,s)a(128-A,Xb(A+A,B-1,r))
 f(T):b(T,8,r)

All strings of length=8, made of "s" and "r" can be made by f(1 to 255), 
but for "srrrrrrr" ans "rrrrrrrr". 

**Sample Code 3 [#m2a60bf8]
 a(T,X):X
 b(A,B):lb(A-81,B)a(82-A,llsb(A+A+A,B-1))
 f(T):b(T,5)

**Examples [#zd71cd08]
-[[Problem 1507]]
-[[Problem 1508]]
-[[Problem 1509]]
-[[Problem 1510]]
-[[Problem 1511]]

*Truncate a multiple recusion [#k0e6b7d4]
**Sample Code 1 [#c8d3ccff]
 f(X,T):rXf(f(sX,T-1),10)
 f(,1)
**Sample Code 2 [#vaabab5f]
 f(X,T):Xf(rf(sX,T-1),10)
 f(,1)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS