Mapping two integers to one, in a unique and deterministic way

前端 未结 19 2139
不知归路
不知归路 2020-11-22 09:35

Imagine two positive integers A and B. I want to combine these two into a single integer C.

There can be no other integers D and E which combine to C. So combining

19条回答
  •  长发绾君心
    2020-11-22 10:10

    let us have two number B and C , encoding them into single number A

    A = B + C * N

    where

    B=A % N = B

    C=A / N = C

提交回复
热议问题