a−1=b−1=−∞ an=bm= +∞
i∈ {0, . . . , n −1}A k ∈ {0, . . . , m}B
bk−1< aibk> ai
xi+k=ai
k aiO(1) m
O(1)
A B X
W1(n, m) = O(n+m)
i= 0, . . . , b√ncαi=ai√nj= 0, . . . , b√mcβj=bj√m
α−1=β−1 = −∞ αb√nc+1 =βb√mc+1 = +∞
i= 0, . . . , b√ncµi∈ {0, . . . , b√mc+ 1}βµi−1< αi< βµi
j= 0, . . . , b√mcνj∈ {0, . . . , b√nc+ 1}ανj−1< βj< ανj
µiνjO(1)
O(n+m)
O(log log n)
O(nlog log n)
D(n, m) = O(log log n)
O(n+m)