素因数分解を思い出そうぜ(^~^)?

読了目安:92分

きふわらべRPG で素因数分解を使う

ramen-tabero-futsu2.png
「 きふわらべRPGで 素因数分解したいんで、素因数分解を思い出そうぜ?」

kifuwarabe-futsu.png
「 1人でやってくれだぜ」

ohkina-hiyoko-futsu2.png
「 合成数を 素数だけで 割り切ればいいのよ」

ramen-tabero-futsu2.png
「 👇 割るしかないの?」

📖 素因数分解とは?やり方を5つのステップでわかりやすく解説【例題・応用問題付き】

kifuwarabe-futsu.png
「 👇 ポラードのロー法 というのがあるらしいぜ」

📖 素因数分解の高速なアルゴリズム(ロー法)

ramen-tabero-futsu2.png
「 分からん。割ることにする」

RPGの戦闘シーンのダメージ計算で使う

ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。

ramen-tabero-futsu2.png
「 👆 じゃあ 試しに n=30 ならどうだぜ?」

ohkina-hiyoko-futsu2.png
「 5×5かける……、5×3×2=30、 5×3×2 しかなくない?」

kifuwarabe-futsu.png
「 どういうアルゴリズムだぜ?」

ohkina-hiyoko-futsu2.png
「 だから 割るのよ」

愚直に書くと

# 素因数分解の練習

print("""\
ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。
""")

print("Please input number:")
n = int(input())

def factorize(n):

    for a in reversed(range(1,101)):
        aa = 7 ** a

        # n 以下の小さな合成数 7a なら、とりあえず n から、それを引く
        if aa <= n:
            remain = n - aa
            print(f"(7x{a}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [a, 0, 0, 0]

            # 余った数で続きをやる

            for b in reversed(range(1,101)):
                bb = aa * 5 ** b

                if bb <= n:
                    remain = n - bb
                    print(f"\t(7x{a} x 5x{b}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [a, b, 0, 0]

                    # 余った数で続きをやる

                    for c in reversed(range(1,101)):
                        cc = bb * 3 ** c

                        if cc <= n:
                            remain = n - cc
                            print(f"\t\t(7x{a} x 5x{b} x 3x{c}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [a, b, c, 0]

                            # 余った数で続きをやる

                            for d in reversed(range(1,101)):
                                dd = cc * 2 ** d

                                if dd <= n:
                                    remain = n - dd
                                    print(f"\t\t\t(7x{a} x 5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                                    # 割り切れた
                                    if remain == 0:
                                        return [a, b, c, d]

    for b in reversed(range(1,101)):
        bb = 5 ** b

        if bb <= n:
            remain = n - bb
            print(f"(5x{b}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [0, b, 0, 0]

            # 余った数で続きをやる

            for c in reversed(range(1,101)):
                cc = bb * 3 ** c

                if cc <= n:
                    remain = n - cc
                    print(f"\t(5x{b} x 3x{c}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [0, b, c, 0]

                    # 余った数で続きをやる

                    for d in reversed(range(1,101)):
                        dd = cc * 2 ** d

                        if dd <= n:
                            remain = n - dd
                            print(f"\t\t(5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [0, b, c, d]

    for c in reversed(range(1,101)):
        cc = 3 ** c

        if cc <= n:
            remain = n - cc
            print(f"(3x{c}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [0, 0, c, 0]

            # 余った数で続きをやる

            for d in reversed(range(1,101)):
                dd = cc * 2 ** d

                if dd <= n:
                    remain = n - dd
                    print(f"\t(3x{c} x 2x{d}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [0, 0, c, d]

    for d in reversed(range(1,101)):
        dd = 2 ** d

        if dd <= n:
            remain = n - dd
            print(f"(2x{d}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [0, 0, 0, d]

print(f"Anser:{factorize(n)}")

ramen-tabero-futsu2.png
「 👆 愚直に書くと こうか」

ohkina-hiyoko-futsu2.png
「 ややこしいから 一般化しなくてよくない?」

n = 1~100 まで見てみよう

ramen-tabero-futsu2.png
「 👇 n を 1 から 100 まで入れてみようぜ?」

N=1 Answer=None
N=2 Answer=[0, 0, 0, 1]
N=3 Answer=[0, 0, 1, 0]
N=4 Answer=[0, 0, 0, 2]
N=5 Answer=[0, 1, 0, 0]
N=6 Answer=[0, 0, 1, 1]
N=7 Answer=[1, 0, 0, 0]
N=8 Answer=[0, 0, 0, 3]
N=9 Answer=[0, 0, 2, 0]
N=10 Answer=None
N=11 Answer=None
N=12 Answer=[0, 0, 1, 2]
N=13 Answer=None
N=14 Answer=None
N=15 Answer=[0, 1, 1, 0]
N=16 Answer=[0, 0, 0, 4]
N=17 Answer=None
N=18 Answer=[0, 0, 2, 1]
N=19 Answer=None
N=20 Answer=None
N=21 Answer=None
N=22 Answer=None
N=23 Answer=None
N=24 Answer=[0, 0, 1, 3]
N=25 Answer=[0, 2, 0, 0]
N=26 Answer=None
N=27 Answer=[0, 0, 3, 0]
N=28 Answer=None
N=29 Answer=None
N=30 Answer=[0, 1, 1, 1]
N=31 Answer=None
N=32 Answer=[0, 0, 0, 5]
N=33 Answer=None
N=34 Answer=None
N=35 Answer=[1, 1, 0, 0]
N=36 Answer=[0, 0, 2, 2]
N=37 Answer=None
N=38 Answer=None
N=39 Answer=None
N=40 Answer=None
N=41 Answer=None
N=42 Answer=None
N=43 Answer=None
N=44 Answer=None
N=45 Answer=[0, 1, 2, 0]
N=46 Answer=None
N=47 Answer=None
N=48 Answer=[0, 0, 1, 4]
N=49 Answer=[2, 0, 0, 0]
N=50 Answer=None
N=51 Answer=None
N=52 Answer=None
N=53 Answer=None
N=54 Answer=[0, 0, 3, 1]
N=55 Answer=None
N=56 Answer=None
N=57 Answer=None
N=58 Answer=None
N=59 Answer=None
N=60 Answer=[0, 1, 1, 2]
N=61 Answer=None
N=62 Answer=None
N=63 Answer=None
N=64 Answer=[0, 0, 0, 6]
N=65 Answer=None
N=66 Answer=None
N=67 Answer=None
N=68 Answer=None
N=69 Answer=None
N=70 Answer=None
N=71 Answer=None
N=72 Answer=[0, 0, 2, 3]
N=73 Answer=None
N=74 Answer=None
N=75 Answer=[0, 2, 1, 0]
N=76 Answer=None
N=77 Answer=None
N=78 Answer=None
N=79 Answer=None
N=80 Answer=None
N=81 Answer=[0, 0, 4, 0]
N=82 Answer=None
N=83 Answer=None
N=84 Answer=None
N=85 Answer=None
N=86 Answer=None
N=87 Answer=None
N=88 Answer=None
N=89 Answer=None
N=90 Answer=[0, 1, 2, 1]
N=91 Answer=None
N=92 Answer=None
N=93 Answer=None
N=94 Answer=None
N=95 Answer=None
N=96 Answer=[0, 0, 1, 5]
N=97 Answer=None
N=98 Answer=None
N=99 Answer=None
N=100 Answer=None

ramen-tabero-futsu2.png
「 👆 20 は 5*2*2 だろ。ミスってんのかな?」

kifuwarabe-futsu.png
「 お父んのループ、3の倍数が0のケースを 表現できてないんだぜ」

ramen-tabero-futsu2.png
「 なるほど」

0乗は1

ohkina-hiyoko-futsu2.png
「 0乗は1 だから、ループで 0 まで回せばいいんじゃないの?」

ramen-tabero-futsu2.png
「 それだぜ」

# 素因数分解の練習
#
# cd math/prime_factorization
# python step1.py

def factorize(n, debug=True):

    for a in reversed(range(0,101)):
        aa = 7 ** a

        # n 以下の小さな合成数 7a なら、とりあえず n から、それを引く
        if aa <= n:
            remain = n - aa

            if debug:
                print(f"(7x{a}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [a, 0, 0, 0]

            # 余った数で続きをやる

            for b in reversed(range(0,101)):
                bb = aa * 5 ** b

                if bb <= n:
                    remain = n - bb

                    if debug:
                        print(f"\t(7x{a} x 5x{b}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [a, b, 0, 0]

                    # 余った数で続きをやる

                    for c in reversed(range(0,101)):
                        cc = bb * 3 ** c

                        if cc <= n:
                            remain = n - cc

                            if debug:
                                print(f"\t\t(7x{a} x 5x{b} x 3x{c}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [a, b, c, 0]

                            # 余った数で続きをやる

                            for d in reversed(range(0,101)):
                                dd = cc * 2 ** d

                                if dd <= n:
                                    remain = n - dd

                                    if debug:
                                        print(f"\t\t\t(7x{a} x 5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                                    # 割り切れた
                                    if remain == 0:
                                        return [a, b, c, d]


if __name__ == "__main__":

    print("""\
ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。
""")

    print("Please input number:")
    n = int(input())

    print(f"Anser:{factorize(n)}")

ramen-tabero-futsu2.png
「 👆 コードが一気に短くなったな」

次の問い

N=1 Answer=[0, 0, 0, 0]
N=2 Answer=[0, 0, 0, 1]
N=3 Answer=[0, 0, 1, 0]
N=4 Answer=[0, 0, 0, 2]
N=5 Answer=[0, 1, 0, 0]
N=6 Answer=[0, 0, 1, 1]
N=7 Answer=[1, 0, 0, 0]
N=8 Answer=[0, 0, 0, 3]
N=9 Answer=[0, 0, 2, 0]
N=10 Answer=[0, 1, 0, 1]
N=11 Answer=None
N=12 Answer=[0, 0, 1, 2]
N=13 Answer=None
N=14 Answer=[1, 0, 0, 1]
N=15 Answer=[0, 1, 1, 0]
N=16 Answer=[0, 0, 0, 4]
N=17 Answer=None
N=18 Answer=[0, 0, 2, 1]
N=19 Answer=None
N=20 Answer=[0, 1, 0, 2]
N=21 Answer=[1, 0, 1, 0]
N=22 Answer=None
N=23 Answer=None
N=24 Answer=[0, 0, 1, 3]
N=25 Answer=[0, 2, 0, 0]
N=26 Answer=None
N=27 Answer=[0, 0, 3, 0]
N=28 Answer=[1, 0, 0, 2]
N=29 Answer=None
N=30 Answer=[0, 1, 1, 1]
N=31 Answer=None
N=32 Answer=[0, 0, 0, 5]
N=33 Answer=None
N=34 Answer=None
N=35 Answer=[1, 1, 0, 0]
N=36 Answer=[0, 0, 2, 2]
N=37 Answer=None
N=38 Answer=None
N=39 Answer=None
N=40 Answer=[0, 1, 0, 3]
N=41 Answer=None
N=42 Answer=[1, 0, 1, 1]
N=43 Answer=None
N=44 Answer=None
N=45 Answer=[0, 1, 2, 0]
N=46 Answer=None
N=47 Answer=None
N=48 Answer=[0, 0, 1, 4]
N=49 Answer=[2, 0, 0, 0]
N=50 Answer=[0, 2, 0, 1]
N=51 Answer=None
N=52 Answer=None
N=53 Answer=None
N=54 Answer=[0, 0, 3, 1]
N=55 Answer=None
N=56 Answer=[1, 0, 0, 3]
N=57 Answer=None
N=58 Answer=None
N=59 Answer=None
N=60 Answer=[0, 1, 1, 2]
N=61 Answer=None
N=62 Answer=None
N=63 Answer=[1, 0, 2, 0]
N=64 Answer=[0, 0, 0, 6]
N=65 Answer=None
N=66 Answer=None
N=67 Answer=None
N=68 Answer=None
N=69 Answer=None
N=70 Answer=[1, 1, 0, 1]
N=71 Answer=None
N=72 Answer=[0, 0, 2, 3]
N=73 Answer=None
N=74 Answer=None
N=75 Answer=[0, 2, 1, 0]
N=76 Answer=None
N=77 Answer=None
N=78 Answer=None
N=79 Answer=None
N=80 Answer=[0, 1, 0, 4]
N=81 Answer=[0, 0, 4, 0]
N=82 Answer=None
N=83 Answer=None
N=84 Answer=[1, 0, 1, 2]
N=85 Answer=None
N=86 Answer=None
N=87 Answer=None
N=88 Answer=None
N=89 Answer=None
N=90 Answer=[0, 1, 2, 1]
N=91 Answer=None
N=92 Answer=None
N=93 Answer=None
N=94 Answer=None
N=95 Answer=None
N=96 Answer=[0, 0, 1, 5]
N=97 Answer=None
N=98 Answer=[2, 0, 0, 1]
N=99 Answer=None
N=100 Answer=[0, 2, 0, 2]

ramen-tabero-futsu2.png
「 👆 上図を見ると、 [0, 0, 0, 5] は [0, 1, 1, 1] より n が 2個分強いんだが、
素因数分解を使わずに
[0, 0, 0, 5] は [0, 1, 1, 1] より n が 2個分強いということを
計算する方法って ある?」

ohkina-hiyoko-futsu2.png
「 5*3*2+2 = 2^5 だから、素因数から n を計算することはできるけど、」

ohkina-hiyoko-futsu2.png
「 そんな計算したくないわね。無いということにして 早く楽したいわね……」

ramen-tabero-futsu2.png
「 もっと よく見たいので n = 101 ~ 1000 まで 見てみようぜ?」

N=101 Answer=None
N=102 Answer=None
N=103 Answer=None
N=104 Answer=None
N=105 Answer=[1, 1, 1, 0]
N=106 Answer=None
N=107 Answer=None
N=108 Answer=[0, 0, 3, 2]
N=109 Answer=None
N=110 Answer=None
N=111 Answer=None
N=112 Answer=[1, 0, 0, 4]
N=113 Answer=None
N=114 Answer=None
N=115 Answer=None
N=116 Answer=None
N=117 Answer=None
N=118 Answer=None
N=119 Answer=None
N=120 Answer=[0, 1, 1, 3]
N=121 Answer=None
N=122 Answer=None
N=123 Answer=None
N=124 Answer=None
N=125 Answer=[0, 3, 0, 0]
N=126 Answer=[1, 0, 2, 1]
N=127 Answer=None
N=128 Answer=[0, 0, 0, 7]
N=129 Answer=None
N=130 Answer=None
N=131 Answer=None
N=132 Answer=None
N=133 Answer=None
N=134 Answer=None
N=135 Answer=[0, 1, 3, 0]
N=136 Answer=None
N=137 Answer=None
N=138 Answer=None
N=139 Answer=None
N=140 Answer=[1, 1, 0, 2]
N=141 Answer=None
N=142 Answer=None
N=143 Answer=None
N=144 Answer=[0, 0, 2, 4]
N=145 Answer=None
N=146 Answer=None
N=147 Answer=[2, 0, 1, 0]
N=148 Answer=None
N=149 Answer=None
N=150 Answer=[0, 2, 1, 1]
N=151 Answer=None
N=152 Answer=None
N=153 Answer=None
N=154 Answer=None
N=155 Answer=None
N=156 Answer=None
N=157 Answer=None
N=158 Answer=None
N=159 Answer=None
N=160 Answer=[0, 1, 0, 5]
N=161 Answer=None
N=162 Answer=[0, 0, 4, 1]
N=163 Answer=None
N=164 Answer=None
N=165 Answer=None
N=166 Answer=None
N=167 Answer=None
N=168 Answer=[1, 0, 1, 3]
N=169 Answer=None
N=170 Answer=None
N=171 Answer=None
N=172 Answer=None
N=173 Answer=None
N=174 Answer=None
N=175 Answer=[1, 2, 0, 0]
N=176 Answer=None
N=177 Answer=None
N=178 Answer=None
N=179 Answer=None
N=180 Answer=[0, 1, 2, 2]
N=181 Answer=None
N=182 Answer=None
N=183 Answer=None
N=184 Answer=None
N=185 Answer=None
N=186 Answer=None
N=187 Answer=None
N=188 Answer=None
N=189 Answer=[1, 0, 3, 0]
N=190 Answer=None
N=191 Answer=None
N=192 Answer=[0, 0, 1, 6]
N=193 Answer=None
N=194 Answer=None
N=195 Answer=None
N=196 Answer=[2, 0, 0, 2]
N=197 Answer=None
N=198 Answer=None
N=199 Answer=None
N=200 Answer=[0, 2, 0, 3]
N=201 Answer=None
N=202 Answer=None
N=203 Answer=None
N=204 Answer=None
N=205 Answer=None
N=206 Answer=None
N=207 Answer=None
N=208 Answer=None
N=209 Answer=None
N=210 Answer=[1, 1, 1, 1]
N=211 Answer=None
N=212 Answer=None
N=213 Answer=None
N=214 Answer=None
N=215 Answer=None
N=216 Answer=[0, 0, 3, 3]
N=217 Answer=None
N=218 Answer=None
N=219 Answer=None
N=220 Answer=None
N=221 Answer=None
N=222 Answer=None
N=223 Answer=None
N=224 Answer=[1, 0, 0, 5]
N=225 Answer=[0, 2, 2, 0]
N=226 Answer=None
N=227 Answer=None
N=228 Answer=None
N=229 Answer=None
N=230 Answer=None
N=231 Answer=None
N=232 Answer=None
N=233 Answer=None
N=234 Answer=None
N=235 Answer=None
N=236 Answer=None
N=237 Answer=None
N=238 Answer=None
N=239 Answer=None
N=240 Answer=[0, 1, 1, 4]
N=241 Answer=None
N=242 Answer=None
N=243 Answer=[0, 0, 5, 0]
N=244 Answer=None
N=245 Answer=[2, 1, 0, 0]
N=246 Answer=None
N=247 Answer=None
N=248 Answer=None
N=249 Answer=None
N=250 Answer=[0, 3, 0, 1]
N=251 Answer=None
N=252 Answer=[1, 0, 2, 2]
N=253 Answer=None
N=254 Answer=None
N=255 Answer=None
N=256 Answer=[0, 0, 0, 8]
N=257 Answer=None
N=258 Answer=None
N=259 Answer=None
N=260 Answer=None
N=261 Answer=None
N=262 Answer=None
N=263 Answer=None
N=264 Answer=None
N=265 Answer=None
N=266 Answer=None
N=267 Answer=None
N=268 Answer=None
N=269 Answer=None
N=270 Answer=[0, 1, 3, 1]
N=271 Answer=None
N=272 Answer=None
N=273 Answer=None
N=274 Answer=None
N=275 Answer=None
N=276 Answer=None
N=277 Answer=None
N=278 Answer=None
N=279 Answer=None
N=280 Answer=[1, 1, 0, 3]
N=281 Answer=None
N=282 Answer=None
N=283 Answer=None
N=284 Answer=None
N=285 Answer=None
N=286 Answer=None
N=287 Answer=None
N=288 Answer=[0, 0, 2, 5]
N=289 Answer=None
N=290 Answer=None
N=291 Answer=None
N=292 Answer=None
N=293 Answer=None
N=294 Answer=[2, 0, 1, 1]
N=295 Answer=None
N=296 Answer=None
N=297 Answer=None
N=298 Answer=None
N=299 Answer=None
N=300 Answer=[0, 2, 1, 2]
N=301 Answer=None
N=302 Answer=None
N=303 Answer=None
N=304 Answer=None
N=305 Answer=None
N=306 Answer=None
N=307 Answer=None
N=308 Answer=None
N=309 Answer=None
N=310 Answer=None
N=311 Answer=None
N=312 Answer=None
N=313 Answer=None
N=314 Answer=None
N=315 Answer=[1, 1, 2, 0]
N=316 Answer=None
N=317 Answer=None
N=318 Answer=None
N=319 Answer=None
N=320 Answer=[0, 1, 0, 6]
N=321 Answer=None
N=322 Answer=None
N=323 Answer=None
N=324 Answer=[0, 0, 4, 2]
N=325 Answer=None
N=326 Answer=None
N=327 Answer=None
N=328 Answer=None
N=329 Answer=None
N=330 Answer=None
N=331 Answer=None
N=332 Answer=None
N=333 Answer=None
N=334 Answer=None
N=335 Answer=None
N=336 Answer=[1, 0, 1, 4]
N=337 Answer=None
N=338 Answer=None
N=339 Answer=None
N=340 Answer=None
N=341 Answer=None
N=342 Answer=None
N=343 Answer=[3, 0, 0, 0]
N=344 Answer=None
N=345 Answer=None
N=346 Answer=None
N=347 Answer=None
N=348 Answer=None
N=349 Answer=None
N=350 Answer=[1, 2, 0, 1]
N=351 Answer=None
N=352 Answer=None
N=353 Answer=None
N=354 Answer=None
N=355 Answer=None
N=356 Answer=None
N=357 Answer=None
N=358 Answer=None
N=359 Answer=None
N=360 Answer=[0, 1, 2, 3]
N=361 Answer=None
N=362 Answer=None
N=363 Answer=None
N=364 Answer=None
N=365 Answer=None
N=366 Answer=None
N=367 Answer=None
N=368 Answer=None
N=369 Answer=None
N=370 Answer=None
N=371 Answer=None
N=372 Answer=None
N=373 Answer=None
N=374 Answer=None
N=375 Answer=[0, 3, 1, 0]
N=376 Answer=None
N=377 Answer=None
N=378 Answer=[1, 0, 3, 1]
N=379 Answer=None
N=380 Answer=None
N=381 Answer=None
N=382 Answer=None
N=383 Answer=None
N=384 Answer=[0, 0, 1, 7]
N=385 Answer=None
N=386 Answer=None
N=387 Answer=None
N=388 Answer=None
N=389 Answer=None
N=390 Answer=None
N=391 Answer=None
N=392 Answer=[2, 0, 0, 3]
N=393 Answer=None
N=394 Answer=None
N=395 Answer=None
N=396 Answer=None
N=397 Answer=None
N=398 Answer=None
N=399 Answer=None
N=400 Answer=[0, 2, 0, 4]
N=401 Answer=None
N=402 Answer=None
N=403 Answer=None
N=404 Answer=None
N=405 Answer=[0, 1, 4, 0]
N=406 Answer=None
N=407 Answer=None
N=408 Answer=None
N=409 Answer=None
N=410 Answer=None
N=411 Answer=None
N=412 Answer=None
N=413 Answer=None
N=414 Answer=None
N=415 Answer=None
N=416 Answer=None
N=417 Answer=None
N=418 Answer=None
N=419 Answer=None
N=420 Answer=[1, 1, 1, 2]
N=421 Answer=None
N=422 Answer=None
N=423 Answer=None
N=424 Answer=None
N=425 Answer=None
N=426 Answer=None
N=427 Answer=None
N=428 Answer=None
N=429 Answer=None
N=430 Answer=None
N=431 Answer=None
N=432 Answer=[0, 0, 3, 4]
N=433 Answer=None
N=434 Answer=None
N=435 Answer=None
N=436 Answer=None
N=437 Answer=None
N=438 Answer=None
N=439 Answer=None
N=440 Answer=None
N=441 Answer=[2, 0, 2, 0]
N=442 Answer=None
N=443 Answer=None
N=444 Answer=None
N=445 Answer=None
N=446 Answer=None
N=447 Answer=None
N=448 Answer=[1, 0, 0, 6]
N=449 Answer=None
N=450 Answer=[0, 2, 2, 1]
N=451 Answer=None
N=452 Answer=None
N=453 Answer=None
N=454 Answer=None
N=455 Answer=None
N=456 Answer=None
N=457 Answer=None
N=458 Answer=None
N=459 Answer=None
N=460 Answer=None
N=461 Answer=None
N=462 Answer=None
N=463 Answer=None
N=464 Answer=None
N=465 Answer=None
N=466 Answer=None
N=467 Answer=None
N=468 Answer=None
N=469 Answer=None
N=470 Answer=None
N=471 Answer=None
N=472 Answer=None
N=473 Answer=None
N=474 Answer=None
N=475 Answer=None
N=476 Answer=None
N=477 Answer=None
N=478 Answer=None
N=479 Answer=None
N=480 Answer=[0, 1, 1, 5]
N=481 Answer=None
N=482 Answer=None
N=483 Answer=None
N=484 Answer=None
N=485 Answer=None
N=486 Answer=[0, 0, 5, 1]
N=487 Answer=None
N=488 Answer=None
N=489 Answer=None
N=490 Answer=[2, 1, 0, 1]
N=491 Answer=None
N=492 Answer=None
N=493 Answer=None
N=494 Answer=None
N=495 Answer=None
N=496 Answer=None
N=497 Answer=None
N=498 Answer=None
N=499 Answer=None
N=500 Answer=[0, 3, 0, 2]
N=501 Answer=None
N=502 Answer=None
N=503 Answer=None
N=504 Answer=[1, 0, 2, 3]
N=505 Answer=None
N=506 Answer=None
N=507 Answer=None
N=508 Answer=None
N=509 Answer=None
N=510 Answer=None
N=511 Answer=None
N=512 Answer=[0, 0, 0, 9]
N=513 Answer=None
N=514 Answer=None
N=515 Answer=None
N=516 Answer=None
N=517 Answer=None
N=518 Answer=None
N=519 Answer=None
N=520 Answer=None
N=521 Answer=None
N=522 Answer=None
N=523 Answer=None
N=524 Answer=None
N=525 Answer=[1, 2, 1, 0]
N=526 Answer=None
N=527 Answer=None
N=528 Answer=None
N=529 Answer=None
N=530 Answer=None
N=531 Answer=None
N=532 Answer=None
N=533 Answer=None
N=534 Answer=None
N=535 Answer=None
N=536 Answer=None
N=537 Answer=None
N=538 Answer=None
N=539 Answer=None
N=540 Answer=[0, 1, 3, 2]
N=541 Answer=None
N=542 Answer=None
N=543 Answer=None
N=544 Answer=None
N=545 Answer=None
N=546 Answer=None
N=547 Answer=None
N=548 Answer=None
N=549 Answer=None
N=550 Answer=None
N=551 Answer=None
N=552 Answer=None
N=553 Answer=None
N=554 Answer=None
N=555 Answer=None
N=556 Answer=None
N=557 Answer=None
N=558 Answer=None
N=559 Answer=None
N=560 Answer=[1, 1, 0, 4]
N=561 Answer=None
N=562 Answer=None
N=563 Answer=None
N=564 Answer=None
N=565 Answer=None
N=566 Answer=None
N=567 Answer=[1, 0, 4, 0]
N=568 Answer=None
N=569 Answer=None
N=570 Answer=None
N=571 Answer=None
N=572 Answer=None
N=573 Answer=None
N=574 Answer=None
N=575 Answer=None
N=576 Answer=[0, 0, 2, 6]
N=577 Answer=None
N=578 Answer=None
N=579 Answer=None
N=580 Answer=None
N=581 Answer=None
N=582 Answer=None
N=583 Answer=None
N=584 Answer=None
N=585 Answer=None
N=586 Answer=None
N=587 Answer=None
N=588 Answer=[2, 0, 1, 2]
N=589 Answer=None
N=590 Answer=None
N=591 Answer=None
N=592 Answer=None
N=593 Answer=None
N=594 Answer=None
N=595 Answer=None
N=596 Answer=None
N=597 Answer=None
N=598 Answer=None
N=599 Answer=None
N=600 Answer=[0, 2, 1, 3]
N=601 Answer=None
N=602 Answer=None
N=603 Answer=None
N=604 Answer=None
N=605 Answer=None
N=606 Answer=None
N=607 Answer=None
N=608 Answer=None
N=609 Answer=None
N=610 Answer=None
N=611 Answer=None
N=612 Answer=None
N=613 Answer=None
N=614 Answer=None
N=615 Answer=None
N=616 Answer=None
N=617 Answer=None
N=618 Answer=None
N=619 Answer=None
N=620 Answer=None
N=621 Answer=None
N=622 Answer=None
N=623 Answer=None
N=624 Answer=None
N=625 Answer=[0, 4, 0, 0]
N=626 Answer=None
N=627 Answer=None
N=628 Answer=None
N=629 Answer=None
N=630 Answer=[1, 1, 2, 1]
N=631 Answer=None
N=632 Answer=None
N=633 Answer=None
N=634 Answer=None
N=635 Answer=None
N=636 Answer=None
N=637 Answer=None
N=638 Answer=None
N=639 Answer=None
N=640 Answer=[0, 1, 0, 7]
N=641 Answer=None
N=642 Answer=None
N=643 Answer=None
N=644 Answer=None
N=645 Answer=None
N=646 Answer=None
N=647 Answer=None
N=648 Answer=[0, 0, 4, 3]
N=649 Answer=None
N=650 Answer=None
N=651 Answer=None
N=652 Answer=None
N=653 Answer=None
N=654 Answer=None
N=655 Answer=None
N=656 Answer=None
N=657 Answer=None
N=658 Answer=None
N=659 Answer=None
N=660 Answer=None
N=661 Answer=None
N=662 Answer=None
N=663 Answer=None
N=664 Answer=None
N=665 Answer=None
N=666 Answer=None
N=667 Answer=None
N=668 Answer=None
N=669 Answer=None
N=670 Answer=None
N=671 Answer=None
N=672 Answer=[1, 0, 1, 5]
N=673 Answer=None
N=674 Answer=None
N=675 Answer=[0, 2, 3, 0]
N=676 Answer=None
N=677 Answer=None
N=678 Answer=None
N=679 Answer=None
N=680 Answer=None
N=681 Answer=None
N=682 Answer=None
N=683 Answer=None
N=684 Answer=None
N=685 Answer=None
N=686 Answer=[3, 0, 0, 1]
N=687 Answer=None
N=688 Answer=None
N=689 Answer=None
N=690 Answer=None
N=691 Answer=None
N=692 Answer=None
N=693 Answer=None
N=694 Answer=None
N=695 Answer=None
N=696 Answer=None
N=697 Answer=None
N=698 Answer=None
N=699 Answer=None
N=700 Answer=[1, 2, 0, 2]
N=701 Answer=None
N=702 Answer=None
N=703 Answer=None
N=704 Answer=None
N=705 Answer=None
N=706 Answer=None
N=707 Answer=None
N=708 Answer=None
N=709 Answer=None
N=710 Answer=None
N=711 Answer=None
N=712 Answer=None
N=713 Answer=None
N=714 Answer=None
N=715 Answer=None
N=716 Answer=None
N=717 Answer=None
N=718 Answer=None
N=719 Answer=None
N=720 Answer=[0, 1, 2, 4]
N=721 Answer=None
N=722 Answer=None
N=723 Answer=None
N=724 Answer=None
N=725 Answer=None
N=726 Answer=None
N=727 Answer=None
N=728 Answer=None
N=729 Answer=[0, 0, 6, 0]
N=730 Answer=None
N=731 Answer=None
N=732 Answer=None
N=733 Answer=None
N=734 Answer=None
N=735 Answer=[2, 1, 1, 0]
N=736 Answer=None
N=737 Answer=None
N=738 Answer=None
N=739 Answer=None
N=740 Answer=None
N=741 Answer=None
N=742 Answer=None
N=743 Answer=None
N=744 Answer=None
N=745 Answer=None
N=746 Answer=None
N=747 Answer=None
N=748 Answer=None
N=749 Answer=None
N=750 Answer=[0, 3, 1, 1]
N=751 Answer=None
N=752 Answer=None
N=753 Answer=None
N=754 Answer=None
N=755 Answer=None
N=756 Answer=[1, 0, 3, 2]
N=757 Answer=None
N=758 Answer=None
N=759 Answer=None
N=760 Answer=None
N=761 Answer=None
N=762 Answer=None
N=763 Answer=None
N=764 Answer=None
N=765 Answer=None
N=766 Answer=None
N=767 Answer=None
N=768 Answer=[0, 0, 1, 8]
N=769 Answer=None
N=770 Answer=None
N=771 Answer=None
N=772 Answer=None
N=773 Answer=None
N=774 Answer=None
N=775 Answer=None
N=776 Answer=None
N=777 Answer=None
N=778 Answer=None
N=779 Answer=None
N=780 Answer=None
N=781 Answer=None
N=782 Answer=None
N=783 Answer=None
N=784 Answer=[2, 0, 0, 4]
N=785 Answer=None
N=786 Answer=None
N=787 Answer=None
N=788 Answer=None
N=789 Answer=None
N=790 Answer=None
N=791 Answer=None
N=792 Answer=None
N=793 Answer=None
N=794 Answer=None
N=795 Answer=None
N=796 Answer=None
N=797 Answer=None
N=798 Answer=None
N=799 Answer=None
N=800 Answer=[0, 2, 0, 5]
N=801 Answer=None
N=802 Answer=None
N=803 Answer=None
N=804 Answer=None
N=805 Answer=None
N=806 Answer=None
N=807 Answer=None
N=808 Answer=None
N=809 Answer=None
N=810 Answer=[0, 1, 4, 1]
N=811 Answer=None
N=812 Answer=None
N=813 Answer=None
N=814 Answer=None
N=815 Answer=None
N=816 Answer=None
N=817 Answer=None
N=818 Answer=None
N=819 Answer=None
N=820 Answer=None
N=821 Answer=None
N=822 Answer=None
N=823 Answer=None
N=824 Answer=None
N=825 Answer=None
N=826 Answer=None
N=827 Answer=None
N=828 Answer=None
N=829 Answer=None
N=830 Answer=None
N=831 Answer=None
N=832 Answer=None
N=833 Answer=None
N=834 Answer=None
N=835 Answer=None
N=836 Answer=None
N=837 Answer=None
N=838 Answer=None
N=839 Answer=None
N=840 Answer=[1, 1, 1, 3]
N=841 Answer=None
N=842 Answer=None
N=843 Answer=None
N=844 Answer=None
N=845 Answer=None
N=846 Answer=None
N=847 Answer=None
N=848 Answer=None
N=849 Answer=None
N=850 Answer=None
N=851 Answer=None
N=852 Answer=None
N=853 Answer=None
N=854 Answer=None
N=855 Answer=None
N=856 Answer=None
N=857 Answer=None
N=858 Answer=None
N=859 Answer=None
N=860 Answer=None
N=861 Answer=None
N=862 Answer=None
N=863 Answer=None
N=864 Answer=[0, 0, 3, 5]
N=865 Answer=None
N=866 Answer=None
N=867 Answer=None
N=868 Answer=None
N=869 Answer=None
N=870 Answer=None
N=871 Answer=None
N=872 Answer=None
N=873 Answer=None
N=874 Answer=None
N=875 Answer=[1, 3, 0, 0]
N=876 Answer=None
N=877 Answer=None
N=878 Answer=None
N=879 Answer=None
N=880 Answer=None
N=881 Answer=None
N=882 Answer=[2, 0, 2, 1]
N=883 Answer=None
N=884 Answer=None
N=885 Answer=None
N=886 Answer=None
N=887 Answer=None
N=888 Answer=None
N=889 Answer=None
N=890 Answer=None
N=891 Answer=None
N=892 Answer=None
N=893 Answer=None
N=894 Answer=None
N=895 Answer=None
N=896 Answer=[1, 0, 0, 7]
N=897 Answer=None
N=898 Answer=None
N=899 Answer=None
N=900 Answer=[0, 2, 2, 2]
N=901 Answer=None
N=902 Answer=None
N=903 Answer=None
N=904 Answer=None
N=905 Answer=None
N=906 Answer=None
N=907 Answer=None
N=908 Answer=None
N=909 Answer=None
N=910 Answer=None
N=911 Answer=None
N=912 Answer=None
N=913 Answer=None
N=914 Answer=None
N=915 Answer=None
N=916 Answer=None
N=917 Answer=None
N=918 Answer=None
N=919 Answer=None
N=920 Answer=None
N=921 Answer=None
N=922 Answer=None
N=923 Answer=None
N=924 Answer=None
N=925 Answer=None
N=926 Answer=None
N=927 Answer=None
N=928 Answer=None
N=929 Answer=None
N=930 Answer=None
N=931 Answer=None
N=932 Answer=None
N=933 Answer=None
N=934 Answer=None
N=935 Answer=None
N=936 Answer=None
N=937 Answer=None
N=938 Answer=None
N=939 Answer=None
N=940 Answer=None
N=941 Answer=None
N=942 Answer=None
N=943 Answer=None
N=944 Answer=None
N=945 Answer=[1, 1, 3, 0]
N=946 Answer=None
N=947 Answer=None
N=948 Answer=None
N=949 Answer=None
N=950 Answer=None
N=951 Answer=None
N=952 Answer=None
N=953 Answer=None
N=954 Answer=None
N=955 Answer=None
N=956 Answer=None
N=957 Answer=None
N=958 Answer=None
N=959 Answer=None
N=960 Answer=[0, 1, 1, 6]
N=961 Answer=None
N=962 Answer=None
N=963 Answer=None
N=964 Answer=None
N=965 Answer=None
N=966 Answer=None
N=967 Answer=None
N=968 Answer=None
N=969 Answer=None
N=970 Answer=None
N=971 Answer=None
N=972 Answer=[0, 0, 5, 2]
N=973 Answer=None
N=974 Answer=None
N=975 Answer=None
N=976 Answer=None
N=977 Answer=None
N=978 Answer=None
N=979 Answer=None
N=980 Answer=[2, 1, 0, 2]
N=981 Answer=None
N=982 Answer=None
N=983 Answer=None
N=984 Answer=None
N=985 Answer=None
N=986 Answer=None
N=987 Answer=None
N=988 Answer=None
N=989 Answer=None
N=990 Answer=None
N=991 Answer=None
N=992 Answer=None
N=993 Answer=None
N=994 Answer=None
N=995 Answer=None
N=996 Answer=None
N=997 Answer=None
N=998 Answer=None
N=999 Answer=None
N=1000 Answer=[0, 3, 0, 3]

kifuwarabe-futsu.png
「 👆 満足かだぜ、お父ん?」

ramen-tabero-futsu2.png
「 過疎化してくんだなあ」

割り切れる数だけ並べるとどうなる?

ramen-tabero-futsu2.png
「 割り切れる数だけ並べるとどうなるんだぜ?」

(0) n=1 Answer=[0, 0, 0, 0]
(1) n=2 Answer=[0, 0, 0, 1]
(2) n=3 Answer=[0, 0, 1, 0]
(3) n=4 Answer=[0, 0, 0, 2]
(4) n=5 Answer=[0, 1, 0, 0]
(5) n=6 Answer=[0, 0, 1, 1]
(6) n=7 Answer=[1, 0, 0, 0]
(7) n=8 Answer=[0, 0, 0, 3]
(8) n=9 Answer=[0, 0, 2, 0]
(9) n=10 Answer=[0, 1, 0, 1]
(10) n=12 Answer=[0, 0, 1, 2]
(11) n=14 Answer=[1, 0, 0, 1]
(12) n=15 Answer=[0, 1, 1, 0]
(13) n=16 Answer=[0, 0, 0, 4]
(14) n=18 Answer=[0, 0, 2, 1]
(15) n=20 Answer=[0, 1, 0, 2]
(16) n=21 Answer=[1, 0, 1, 0]
(17) n=24 Answer=[0, 0, 1, 3]
(18) n=25 Answer=[0, 2, 0, 0]
(19) n=27 Answer=[0, 0, 3, 0]
(20) n=28 Answer=[1, 0, 0, 2]
(21) n=30 Answer=[0, 1, 1, 1]
(22) n=32 Answer=[0, 0, 0, 5]
(23) n=35 Answer=[1, 1, 0, 0]
(24) n=36 Answer=[0, 0, 2, 2]
(25) n=40 Answer=[0, 1, 0, 3]
(26) n=42 Answer=[1, 0, 1, 1]
(27) n=45 Answer=[0, 1, 2, 0]
(28) n=48 Answer=[0, 0, 1, 4]
(29) n=49 Answer=[2, 0, 0, 0]
(30) n=50 Answer=[0, 2, 0, 1]
(31) n=54 Answer=[0, 0, 3, 1]
(32) n=56 Answer=[1, 0, 0, 3]
(33) n=60 Answer=[0, 1, 1, 2]
(34) n=63 Answer=[1, 0, 2, 0]
(35) n=64 Answer=[0, 0, 0, 6]
(36) n=70 Answer=[1, 1, 0, 1]
(37) n=72 Answer=[0, 0, 2, 3]
(38) n=75 Answer=[0, 2, 1, 0]
(39) n=80 Answer=[0, 1, 0, 4]
(40) n=81 Answer=[0, 0, 4, 0]
(41) n=84 Answer=[1, 0, 1, 2]
(42) n=90 Answer=[0, 1, 2, 1]
(43) n=96 Answer=[0, 0, 1, 5]
(44) n=98 Answer=[2, 0, 0, 1]
(45) n=100 Answer=[0, 2, 0, 2]
(46) n=105 Answer=[1, 1, 1, 0]
(47) n=108 Answer=[0, 0, 3, 2]
(48) n=112 Answer=[1, 0, 0, 4]
(49) n=120 Answer=[0, 1, 1, 3]
(50) n=125 Answer=[0, 3, 0, 0]
(51) n=126 Answer=[1, 0, 2, 1]
(52) n=128 Answer=[0, 0, 0, 7]
(53) n=135 Answer=[0, 1, 3, 0]
(54) n=140 Answer=[1, 1, 0, 2]
(55) n=144 Answer=[0, 0, 2, 4]
(56) n=147 Answer=[2, 0, 1, 0]
(57) n=150 Answer=[0, 2, 1, 1]
(58) n=160 Answer=[0, 1, 0, 5]
(59) n=162 Answer=[0, 0, 4, 1]
(60) n=168 Answer=[1, 0, 1, 3]
(61) n=175 Answer=[1, 2, 0, 0]
(62) n=180 Answer=[0, 1, 2, 2]
(63) n=189 Answer=[1, 0, 3, 0]
(64) n=192 Answer=[0, 0, 1, 6]
(65) n=196 Answer=[2, 0, 0, 2]
(66) n=200 Answer=[0, 2, 0, 3]
(67) n=210 Answer=[1, 1, 1, 1]
(68) n=216 Answer=[0, 0, 3, 3]
(69) n=224 Answer=[1, 0, 0, 5]
(70) n=225 Answer=[0, 2, 2, 0]
(71) n=240 Answer=[0, 1, 1, 4]
(72) n=243 Answer=[0, 0, 5, 0]
(73) n=245 Answer=[2, 1, 0, 0]
(74) n=250 Answer=[0, 3, 0, 1]
(75) n=252 Answer=[1, 0, 2, 2]
(76) n=256 Answer=[0, 0, 0, 8]
(77) n=270 Answer=[0, 1, 3, 1]
(78) n=280 Answer=[1, 1, 0, 3]
(79) n=288 Answer=[0, 0, 2, 5]
(80) n=294 Answer=[2, 0, 1, 1]
(81) n=300 Answer=[0, 2, 1, 2]
(82) n=315 Answer=[1, 1, 2, 0]
(83) n=320 Answer=[0, 1, 0, 6]
(84) n=324 Answer=[0, 0, 4, 2]
(85) n=336 Answer=[1, 0, 1, 4]
(86) n=343 Answer=[3, 0, 0, 0]
(87) n=350 Answer=[1, 2, 0, 1]
(88) n=360 Answer=[0, 1, 2, 3]
(89) n=375 Answer=[0, 3, 1, 0]
(90) n=378 Answer=[1, 0, 3, 1]
(91) n=384 Answer=[0, 0, 1, 7]
(92) n=392 Answer=[2, 0, 0, 3]
(93) n=400 Answer=[0, 2, 0, 4]
(94) n=405 Answer=[0, 1, 4, 0]
(95) n=420 Answer=[1, 1, 1, 2]
(96) n=432 Answer=[0, 0, 3, 4]
(97) n=441 Answer=[2, 0, 2, 0]
(98) n=448 Answer=[1, 0, 0, 6]
(99) n=450 Answer=[0, 2, 2, 1]
(100) n=480 Answer=[0, 1, 1, 5]
(101) n=486 Answer=[0, 0, 5, 1]
(102) n=490 Answer=[2, 1, 0, 1]
(103) n=500 Answer=[0, 3, 0, 2]
(104) n=504 Answer=[1, 0, 2, 3]
(105) n=512 Answer=[0, 0, 0, 9]
(106) n=525 Answer=[1, 2, 1, 0]
(107) n=540 Answer=[0, 1, 3, 2]
(108) n=560 Answer=[1, 1, 0, 4]
(109) n=567 Answer=[1, 0, 4, 0]
(110) n=576 Answer=[0, 0, 2, 6]
(111) n=588 Answer=[2, 0, 1, 2]
(112) n=600 Answer=[0, 2, 1, 3]
(113) n=625 Answer=[0, 4, 0, 0]
(114) n=630 Answer=[1, 1, 2, 1]
(115) n=640 Answer=[0, 1, 0, 7]
(116) n=648 Answer=[0, 0, 4, 3]
(117) n=672 Answer=[1, 0, 1, 5]
(118) n=675 Answer=[0, 2, 3, 0]
(119) n=686 Answer=[3, 0, 0, 1]
(120) n=700 Answer=[1, 2, 0, 2]
(121) n=720 Answer=[0, 1, 2, 4]
(122) n=729 Answer=[0, 0, 6, 0]
(123) n=735 Answer=[2, 1, 1, 0]
(124) n=750 Answer=[0, 3, 1, 1]
(125) n=756 Answer=[1, 0, 3, 2]
(126) n=768 Answer=[0, 0, 1, 8]
(127) n=784 Answer=[2, 0, 0, 4]
(128) n=800 Answer=[0, 2, 0, 5]
(129) n=810 Answer=[0, 1, 4, 1]
(130) n=840 Answer=[1, 1, 1, 3]
(131) n=864 Answer=[0, 0, 3, 5]
(132) n=875 Answer=[1, 3, 0, 0]
(133) n=882 Answer=[2, 0, 2, 1]
(134) n=896 Answer=[1, 0, 0, 7]
(135) n=900 Answer=[0, 2, 2, 2]
(136) n=945 Answer=[1, 1, 3, 0]
(137) n=960 Answer=[0, 1, 1, 6]
(138) n=972 Answer=[0, 0, 5, 2]
(139) n=980 Answer=[2, 1, 0, 2]
(140) n=1000 Answer=[0, 3, 0, 3]
(141) n=1008 Answer=[1, 0, 2, 4]
(142) n=1024 Answer=[0, 0, 0, 10]
(143) n=1029 Answer=[3, 0, 1, 0]
(144) n=1050 Answer=[1, 2, 1, 1]
(145) n=1080 Answer=[0, 1, 3, 3]
(146) n=1120 Answer=[1, 1, 0, 5]
(147) n=1125 Answer=[0, 3, 2, 0]
(148) n=1134 Answer=[1, 0, 4, 1]
(149) n=1152 Answer=[0, 0, 2, 7]
(150) n=1176 Answer=[2, 0, 1, 3]
(151) n=1200 Answer=[0, 2, 1, 4]
(152) n=1215 Answer=[0, 1, 5, 0]
(153) n=1225 Answer=[2, 2, 0, 0]
(154) n=1250 Answer=[0, 4, 0, 1]
(155) n=1260 Answer=[1, 1, 2, 2]
(156) n=1280 Answer=[0, 1, 0, 8]
(157) n=1296 Answer=[0, 0, 4, 4]
(158) n=1323 Answer=[2, 0, 3, 0]
(159) n=1344 Answer=[1, 0, 1, 6]
(160) n=1350 Answer=[0, 2, 3, 1]
(161) n=1372 Answer=[3, 0, 0, 2]
(162) n=1400 Answer=[1, 2, 0, 3]
(163) n=1440 Answer=[0, 1, 2, 5]
(164) n=1458 Answer=[0, 0, 6, 1]
(165) n=1470 Answer=[2, 1, 1, 1]
(166) n=1500 Answer=[0, 3, 1, 2]
(167) n=1512 Answer=[1, 0, 3, 3]
(168) n=1536 Answer=[0, 0, 1, 9]
(169) n=1568 Answer=[2, 0, 0, 5]
(170) n=1575 Answer=[1, 2, 2, 0]
(171) n=1600 Answer=[0, 2, 0, 6]
(172) n=1620 Answer=[0, 1, 4, 2]
(173) n=1680 Answer=[1, 1, 1, 4]
(174) n=1701 Answer=[1, 0, 5, 0]
(175) n=1715 Answer=[3, 1, 0, 0]
(176) n=1728 Answer=[0, 0, 3, 6]
(177) n=1750 Answer=[1, 3, 0, 1]
(178) n=1764 Answer=[2, 0, 2, 2]
(179) n=1792 Answer=[1, 0, 0, 8]
(180) n=1800 Answer=[0, 2, 2, 3]
(181) n=1875 Answer=[0, 4, 1, 0]
(182) n=1890 Answer=[1, 1, 3, 1]
(183) n=1920 Answer=[0, 1, 1, 7]
(184) n=1944 Answer=[0, 0, 5, 3]
(185) n=1960 Answer=[2, 1, 0, 3]
(186) n=2000 Answer=[0, 3, 0, 4]
(187) n=2016 Answer=[1, 0, 2, 5]
(188) n=2025 Answer=[0, 2, 4, 0]
(189) n=2048 Answer=[0, 0, 0, 11]
(190) n=2058 Answer=[3, 0, 1, 1]
(191) n=2100 Answer=[1, 2, 1, 2]
(192) n=2160 Answer=[0, 1, 3, 4]
(193) n=2187 Answer=[0, 0, 7, 0]
(194) n=2205 Answer=[2, 1, 2, 0]
(195) n=2240 Answer=[1, 1, 0, 6]
(196) n=2250 Answer=[0, 3, 2, 1]
(197) n=2268 Answer=[1, 0, 4, 2]
(198) n=2304 Answer=[0, 0, 2, 8]
(199) n=2352 Answer=[2, 0, 1, 4]
(200) n=2400 Answer=[0, 2, 1, 5]
(201) n=2401 Answer=[4, 0, 0, 0]
(202) n=2430 Answer=[0, 1, 5, 1]
(203) n=2450 Answer=[2, 2, 0, 1]
(204) n=2500 Answer=[0, 4, 0, 2]
(205) n=2520 Answer=[1, 1, 2, 3]
(206) n=2560 Answer=[0, 1, 0, 9]
(207) n=2592 Answer=[0, 0, 4, 5]
(208) n=2625 Answer=[1, 3, 1, 0]
(209) n=2646 Answer=[2, 0, 3, 1]
(210) n=2688 Answer=[1, 0, 1, 7]
(211) n=2700 Answer=[0, 2, 3, 2]
(212) n=2744 Answer=[3, 0, 0, 3]
(213) n=2800 Answer=[1, 2, 0, 4]
(214) n=2835 Answer=[1, 1, 4, 0]
(215) n=2880 Answer=[0, 1, 2, 6]
(216) n=2916 Answer=[0, 0, 6, 2]
(217) n=2940 Answer=[2, 1, 1, 2]
(218) n=3000 Answer=[0, 3, 1, 3]
(219) n=3024 Answer=[1, 0, 3, 4]
(220) n=3072 Answer=[0, 0, 1, 10]
(221) n=3087 Answer=[3, 0, 2, 0]
(222) n=3125 Answer=[0, 5, 0, 0]
(223) n=3136 Answer=[2, 0, 0, 6]
(224) n=3150 Answer=[1, 2, 2, 1]
(225) n=3200 Answer=[0, 2, 0, 7]
(226) n=3240 Answer=[0, 1, 4, 3]
(227) n=3360 Answer=[1, 1, 1, 5]
(228) n=3375 Answer=[0, 3, 3, 0]
(229) n=3402 Answer=[1, 0, 5, 1]
(230) n=3430 Answer=[3, 1, 0, 1]
(231) n=3456 Answer=[0, 0, 3, 7]
(232) n=3500 Answer=[1, 3, 0, 2]
(233) n=3528 Answer=[2, 0, 2, 3]
(234) n=3584 Answer=[1, 0, 0, 9]
(235) n=3600 Answer=[0, 2, 2, 4]
(236) n=3645 Answer=[0, 1, 6, 0]
(237) n=3675 Answer=[2, 2, 1, 0]
(238) n=3750 Answer=[0, 4, 1, 1]
(239) n=3780 Answer=[1, 1, 3, 2]
(240) n=3840 Answer=[0, 1, 1, 8]
(241) n=3888 Answer=[0, 0, 5, 4]
(242) n=3920 Answer=[2, 1, 0, 4]
(243) n=3969 Answer=[2, 0, 4, 0]
(244) n=4000 Answer=[0, 3, 0, 5]
(245) n=4032 Answer=[1, 0, 2, 6]
(246) n=4050 Answer=[0, 2, 4, 1]
(247) n=4096 Answer=[0, 0, 0, 12]
(248) n=4116 Answer=[3, 0, 1, 2]
(249) n=4200 Answer=[1, 2, 1, 3]
(250) n=4320 Answer=[0, 1, 3, 5]
(251) n=4374 Answer=[0, 0, 7, 1]
(252) n=4375 Answer=[1, 4, 0, 0]
(253) n=4410 Answer=[2, 1, 2, 1]
(254) n=4480 Answer=[1, 1, 0, 7]
(255) n=4500 Answer=[0, 3, 2, 2]
(256) n=4536 Answer=[1, 0, 4, 3]
(257) n=4608 Answer=[0, 0, 2, 9]
(258) n=4704 Answer=[2, 0, 1, 5]
(259) n=4725 Answer=[1, 2, 3, 0]
(260) n=4800 Answer=[0, 2, 1, 6]
(261) n=4802 Answer=[4, 0, 0, 1]
(262) n=4860 Answer=[0, 1, 5, 2]
(263) n=4900 Answer=[2, 2, 0, 2]
(264) n=5000 Answer=[0, 4, 0, 3]
(265) n=5040 Answer=[1, 1, 2, 4]
(266) n=5103 Answer=[1, 0, 6, 0]
(267) n=5120 Answer=[0, 1, 0, 10]
(268) n=5145 Answer=[3, 1, 1, 0]
(269) n=5184 Answer=[0, 0, 4, 6]
(270) n=5250 Answer=[1, 3, 1, 1]
(271) n=5292 Answer=[2, 0, 3, 2]
(272) n=5376 Answer=[1, 0, 1, 8]
(273) n=5400 Answer=[0, 2, 3, 3]
(274) n=5488 Answer=[3, 0, 0, 4]
(275) n=5600 Answer=[1, 2, 0, 5]
(276) n=5625 Answer=[0, 4, 2, 0]
(277) n=5670 Answer=[1, 1, 4, 1]
(278) n=5760 Answer=[0, 1, 2, 7]
(279) n=5832 Answer=[0, 0, 6, 3]
(280) n=5880 Answer=[2, 1, 1, 3]
(281) n=6000 Answer=[0, 3, 1, 4]
(282) n=6048 Answer=[1, 0, 3, 5]
(283) n=6075 Answer=[0, 2, 5, 0]
(284) n=6125 Answer=[2, 3, 0, 0]
(285) n=6144 Answer=[0, 0, 1, 11]
(286) n=6174 Answer=[3, 0, 2, 1]
(287) n=6250 Answer=[0, 5, 0, 1]
(288) n=6272 Answer=[2, 0, 0, 7]
(289) n=6300 Answer=[1, 2, 2, 2]
(290) n=6400 Answer=[0, 2, 0, 8]
(291) n=6480 Answer=[0, 1, 4, 4]
(292) n=6561 Answer=[0, 0, 8, 0]
(293) n=6615 Answer=[2, 1, 3, 0]
(294) n=6720 Answer=[1, 1, 1, 6]
(295) n=6750 Answer=[0, 3, 3, 1]
(296) n=6804 Answer=[1, 0, 5, 2]
(297) n=6860 Answer=[3, 1, 0, 2]
(298) n=6912 Answer=[0, 0, 3, 8]
(299) n=7000 Answer=[1, 3, 0, 3]
(300) n=7056 Answer=[2, 0, 2, 4]
(301) n=7168 Answer=[1, 0, 0, 10]
(302) n=7200 Answer=[0, 2, 2, 5]
(303) n=7203 Answer=[4, 0, 1, 0]
(304) n=7290 Answer=[0, 1, 6, 1]
(305) n=7350 Answer=[2, 2, 1, 1]
(306) n=7500 Answer=[0, 4, 1, 2]
(307) n=7560 Answer=[1, 1, 3, 3]
(308) n=7680 Answer=[0, 1, 1, 9]
(309) n=7776 Answer=[0, 0, 5, 5]
(310) n=7840 Answer=[2, 1, 0, 5]
(311) n=7875 Answer=[1, 3, 2, 0]
(312) n=7938 Answer=[2, 0, 4, 1]
(313) n=8000 Answer=[0, 3, 0, 6]
(314) n=8064 Answer=[1, 0, 2, 7]
(315) n=8100 Answer=[0, 2, 4, 2]
(316) n=8192 Answer=[0, 0, 0, 13]
(317) n=8232 Answer=[3, 0, 1, 3]
(318) n=8400 Answer=[1, 2, 1, 4]
(319) n=8505 Answer=[1, 1, 5, 0]
(320) n=8575 Answer=[3, 2, 0, 0]
(321) n=8640 Answer=[0, 1, 3, 6]
(322) n=8748 Answer=[0, 0, 7, 2]
(323) n=8750 Answer=[1, 4, 0, 1]
(324) n=8820 Answer=[2, 1, 2, 2]
(325) n=8960 Answer=[1, 1, 0, 8]
(326) n=9000 Answer=[0, 3, 2, 3]
(327) n=9072 Answer=[1, 0, 4, 4]
(328) n=9216 Answer=[0, 0, 2, 10]
(329) n=9261 Answer=[3, 0, 3, 0]
(330) n=9375 Answer=[0, 5, 1, 0]
(331) n=9408 Answer=[2, 0, 1, 6]
(332) n=9450 Answer=[1, 2, 3, 1]
(333) n=9600 Answer=[0, 2, 1, 7]
(334) n=9604 Answer=[4, 0, 0, 2]
(335) n=9720 Answer=[0, 1, 5, 3]
(336) n=9800 Answer=[2, 2, 0, 3]
(337) n=10000 Answer=[0, 4, 0, 4]
(338) n=10080 Answer=[1, 1, 2, 5]
(339) n=10125 Answer=[0, 3, 4, 0]
(340) n=10206 Answer=[1, 0, 6, 1]
(341) n=10240 Answer=[0, 1, 0, 11]
(342) n=10290 Answer=[3, 1, 1, 1]
(343) n=10368 Answer=[0, 0, 4, 7]
(344) n=10500 Answer=[1, 3, 1, 2]
(345) n=10584 Answer=[2, 0, 3, 3]
(346) n=10752 Answer=[1, 0, 1, 9]
(347) n=10800 Answer=[0, 2, 3, 4]
(348) n=10935 Answer=[0, 1, 7, 0]
(349) n=10976 Answer=[3, 0, 0, 5]
(350) n=11025 Answer=[2, 2, 2, 0]
(351) n=11200 Answer=[1, 2, 0, 6]
(352) n=11250 Answer=[0, 4, 2, 1]
(353) n=11340 Answer=[1, 1, 4, 2]
(354) n=11520 Answer=[0, 1, 2, 8]
(355) n=11664 Answer=[0, 0, 6, 4]
(356) n=11760 Answer=[2, 1, 1, 4]
(357) n=11907 Answer=[2, 0, 5, 0]
(358) n=12000 Answer=[0, 3, 1, 5]
(359) n=12005 Answer=[4, 1, 0, 0]
(360) n=12096 Answer=[1, 0, 3, 6]
(361) n=12150 Answer=[0, 2, 5, 1]
(362) n=12250 Answer=[2, 3, 0, 1]
(363) n=12288 Answer=[0, 0, 1, 12]
(364) n=12348 Answer=[3, 0, 2, 2]
(365) n=12500 Answer=[0, 5, 0, 2]
(366) n=12544 Answer=[2, 0, 0, 8]
(367) n=12600 Answer=[1, 2, 2, 3]
(368) n=12800 Answer=[0, 2, 0, 9]
(369) n=12960 Answer=[0, 1, 4, 5]
(370) n=13122 Answer=[0, 0, 8, 1]
(371) n=13125 Answer=[1, 4, 1, 0]
(372) n=13230 Answer=[2, 1, 3, 1]
(373) n=13440 Answer=[1, 1, 1, 7]
(374) n=13500 Answer=[0, 3, 3, 2]
(375) n=13608 Answer=[1, 0, 5, 3]
(376) n=13720 Answer=[3, 1, 0, 3]
(377) n=13824 Answer=[0, 0, 3, 9]
(378) n=14000 Answer=[1, 3, 0, 4]
(379) n=14112 Answer=[2, 0, 2, 5]
(380) n=14175 Answer=[1, 2, 4, 0]
(381) n=14336 Answer=[1, 0, 0, 11]
(382) n=14400 Answer=[0, 2, 2, 6]
(383) n=14406 Answer=[4, 0, 1, 1]
(384) n=14580 Answer=[0, 1, 6, 2]
(385) n=14700 Answer=[2, 2, 1, 2]
(386) n=15000 Answer=[0, 4, 1, 3]
(387) n=15120 Answer=[1, 1, 3, 4]
(388) n=15309 Answer=[1, 0, 7, 0]
(389) n=15360 Answer=[0, 1, 1, 10]
(390) n=15435 Answer=[3, 1, 2, 0]
(391) n=15552 Answer=[0, 0, 5, 6]
(392) n=15625 Answer=[0, 6, 0, 0]
(393) n=15680 Answer=[2, 1, 0, 6]
(394) n=15750 Answer=[1, 3, 2, 1]
(395) n=15876 Answer=[2, 0, 4, 2]
(396) n=16000 Answer=[0, 3, 0, 7]
(397) n=16128 Answer=[1, 0, 2, 8]
(398) n=16200 Answer=[0, 2, 4, 3]
(399) n=16384 Answer=[0, 0, 0, 14]
(400) n=16464 Answer=[3, 0, 1, 4]
(401) n=16800 Answer=[1, 2, 1, 5]
(402) n=16807 Answer=[5, 0, 0, 0]
(403) n=16875 Answer=[0, 4, 3, 0]
(404) n=17010 Answer=[1, 1, 5, 1]
(405) n=17150 Answer=[3, 2, 0, 1]
(406) n=17280 Answer=[0, 1, 3, 7]
(407) n=17496 Answer=[0, 0, 7, 3]
(408) n=17500 Answer=[1, 4, 0, 2]
(409) n=17640 Answer=[2, 1, 2, 3]
(410) n=17920 Answer=[1, 1, 0, 9]
(411) n=18000 Answer=[0, 3, 2, 4]
(412) n=18144 Answer=[1, 0, 4, 5]
(413) n=18225 Answer=[0, 2, 6, 0]
(414) n=18375 Answer=[2, 3, 1, 0]
(415) n=18432 Answer=[0, 0, 2, 11]
(416) n=18522 Answer=[3, 0, 3, 1]
(417) n=18750 Answer=[0, 5, 1, 1]
(418) n=18816 Answer=[2, 0, 1, 7]
(419) n=18900 Answer=[1, 2, 3, 2]
(420) n=19200 Answer=[0, 2, 1, 8]
(421) n=19208 Answer=[4, 0, 0, 3]
(422) n=19440 Answer=[0, 1, 5, 4]
(423) n=19600 Answer=[2, 2, 0, 4]
(424) n=19683 Answer=[0, 0, 9, 0]
(425) n=19845 Answer=[2, 1, 4, 0]
(426) n=20000 Answer=[0, 4, 0, 5]
(427) n=20160 Answer=[1, 1, 2, 6]
(428) n=20250 Answer=[0, 3, 4, 1]
(429) n=20412 Answer=[1, 0, 6, 2]
(430) n=20480 Answer=[0, 1, 0, 12]
(431) n=20580 Answer=[3, 1, 1, 2]
(432) n=20736 Answer=[0, 0, 4, 8]
(433) n=21000 Answer=[1, 3, 1, 3]
(434) n=21168 Answer=[2, 0, 3, 4]
(435) n=21504 Answer=[1, 0, 1, 10]
(436) n=21600 Answer=[0, 2, 3, 5]
(437) n=21609 Answer=[4, 0, 2, 0]
(438) n=21870 Answer=[0, 1, 7, 1]
(439) n=21875 Answer=[1, 5, 0, 0]
(440) n=21952 Answer=[3, 0, 0, 6]
(441) n=22050 Answer=[2, 2, 2, 1]
(442) n=22400 Answer=[1, 2, 0, 7]
(443) n=22500 Answer=[0, 4, 2, 2]
(444) n=22680 Answer=[1, 1, 4, 3]
(445) n=23040 Answer=[0, 1, 2, 9]
(446) n=23328 Answer=[0, 0, 6, 5]
(447) n=23520 Answer=[2, 1, 1, 5]
(448) n=23625 Answer=[1, 3, 3, 0]
(449) n=23814 Answer=[2, 0, 5, 1]
(450) n=24000 Answer=[0, 3, 1, 6]
(451) n=24010 Answer=[4, 1, 0, 1]
(452) n=24192 Answer=[1, 0, 3, 7]
(453) n=24300 Answer=[0, 2, 5, 2]
(454) n=24500 Answer=[2, 3, 0, 2]
(455) n=24576 Answer=[0, 0, 1, 13]
(456) n=24696 Answer=[3, 0, 2, 3]
(457) n=25000 Answer=[0, 5, 0, 3]
(458) n=25088 Answer=[2, 0, 0, 9]
(459) n=25200 Answer=[1, 2, 2, 4]
(460) n=25515 Answer=[1, 1, 6, 0]
(461) n=25600 Answer=[0, 2, 0, 10]
(462) n=25725 Answer=[3, 2, 1, 0]
(463) n=25920 Answer=[0, 1, 4, 6]
(464) n=26244 Answer=[0, 0, 8, 2]
(465) n=26250 Answer=[1, 4, 1, 1]
(466) n=26460 Answer=[2, 1, 3, 2]
(467) n=26880 Answer=[1, 1, 1, 8]
(468) n=27000 Answer=[0, 3, 3, 3]
(469) n=27216 Answer=[1, 0, 5, 4]
(470) n=27440 Answer=[3, 1, 0, 4]
(471) n=27648 Answer=[0, 0, 3, 10]
(472) n=27783 Answer=[3, 0, 4, 0]
(473) n=28000 Answer=[1, 3, 0, 5]
(474) n=28125 Answer=[0, 5, 2, 0]
(475) n=28224 Answer=[2, 0, 2, 6]
(476) n=28350 Answer=[1, 2, 4, 1]
(477) n=28672 Answer=[1, 0, 0, 12]
(478) n=28800 Answer=[0, 2, 2, 7]
(479) n=28812 Answer=[4, 0, 1, 2]
(480) n=29160 Answer=[0, 1, 6, 3]
(481) n=29400 Answer=[2, 2, 1, 3]
(482) n=30000 Answer=[0, 4, 1, 4]
(483) n=30240 Answer=[1, 1, 3, 5]
(484) n=30375 Answer=[0, 3, 5, 0]
(485) n=30618 Answer=[1, 0, 7, 1]
(486) n=30625 Answer=[2, 4, 0, 0]
(487) n=30720 Answer=[0, 1, 1, 11]
(488) n=30870 Answer=[3, 1, 2, 1]
(489) n=31104 Answer=[0, 0, 5, 7]
(490) n=31250 Answer=[0, 6, 0, 1]
(491) n=31360 Answer=[2, 1, 0, 7]
(492) n=31500 Answer=[1, 3, 2, 2]
(493) n=31752 Answer=[2, 0, 4, 3]
(494) n=32000 Answer=[0, 3, 0, 8]
(495) n=32256 Answer=[1, 0, 2, 9]
(496) n=32400 Answer=[0, 2, 4, 4]
(497) n=32768 Answer=[0, 0, 0, 15]
(498) n=32805 Answer=[0, 1, 8, 0]
(499) n=32928 Answer=[3, 0, 1, 5]
(500) n=33075 Answer=[2, 2, 3, 0]
(501) n=33600 Answer=[1, 2, 1, 6]
(502) n=33614 Answer=[5, 0, 0, 1]
(503) n=33750 Answer=[0, 4, 3, 1]
(504) n=34020 Answer=[1, 1, 5, 2]
(505) n=34300 Answer=[3, 2, 0, 2]
(506) n=34560 Answer=[0, 1, 3, 8]
(507) n=34992 Answer=[0, 0, 7, 4]
(508) n=35000 Answer=[1, 4, 0, 3]
(509) n=35280 Answer=[2, 1, 2, 4]
(510) n=35721 Answer=[2, 0, 6, 0]
(511) n=35840 Answer=[1, 1, 0, 10]
(512) n=36000 Answer=[0, 3, 2, 5]
(513) n=36015 Answer=[4, 1, 1, 0]
(514) n=36288 Answer=[1, 0, 4, 6]
(515) n=36450 Answer=[0, 2, 6, 1]
(516) n=36750 Answer=[2, 3, 1, 1]
(517) n=36864 Answer=[0, 0, 2, 12]
(518) n=37044 Answer=[3, 0, 3, 2]
(519) n=37500 Answer=[0, 5, 1, 2]
(520) n=37632 Answer=[2, 0, 1, 8]
(521) n=37800 Answer=[1, 2, 3, 3]
(522) n=38400 Answer=[0, 2, 1, 9]
(523) n=38416 Answer=[4, 0, 0, 4]
(524) n=38880 Answer=[0, 1, 5, 5]
(525) n=39200 Answer=[2, 2, 0, 5]
(526) n=39366 Answer=[0, 0, 9, 1]
(527) n=39375 Answer=[1, 4, 2, 0]
(528) n=39690 Answer=[2, 1, 4, 1]
(529) n=40000 Answer=[0, 4, 0, 6]
(530) n=40320 Answer=[1, 1, 2, 7]
(531) n=40500 Answer=[0, 3, 4, 2]
(532) n=40824 Answer=[1, 0, 6, 3]
(533) n=40960 Answer=[0, 1, 0, 13]
(534) n=41160 Answer=[3, 1, 1, 3]
(535) n=41472 Answer=[0, 0, 4, 9]
(536) n=42000 Answer=[1, 3, 1, 4]
(537) n=42336 Answer=[2, 0, 3, 5]
(538) n=42525 Answer=[1, 2, 5, 0]
(539) n=42875 Answer=[3, 3, 0, 0]
(540) n=43008 Answer=[1, 0, 1, 11]
(541) n=43200 Answer=[0, 2, 3, 6]
(542) n=43218 Answer=[4, 0, 2, 1]
(543) n=43740 Answer=[0, 1, 7, 2]
(544) n=43750 Answer=[1, 5, 0, 1]
(545) n=43904 Answer=[3, 0, 0, 7]
(546) n=44100 Answer=[2, 2, 2, 2]
(547) n=44800 Answer=[1, 2, 0, 8]
(548) n=45000 Answer=[0, 4, 2, 3]
(549) n=45360 Answer=[1, 1, 4, 4]
(550) n=45927 Answer=[1, 0, 8, 0]
(551) n=46080 Answer=[0, 1, 2, 10]
(552) n=46305 Answer=[3, 1, 3, 0]
(553) n=46656 Answer=[0, 0, 6, 6]
(554) n=46875 Answer=[0, 6, 1, 0]
(555) n=47040 Answer=[2, 1, 1, 6]
(556) n=47250 Answer=[1, 3, 3, 1]
(557) n=47628 Answer=[2, 0, 5, 2]
(558) n=48000 Answer=[0, 3, 1, 7]
(559) n=48020 Answer=[4, 1, 0, 2]
(560) n=48384 Answer=[1, 0, 3, 8]
(561) n=48600 Answer=[0, 2, 5, 3]
(562) n=49000 Answer=[2, 3, 0, 3]
(563) n=49152 Answer=[0, 0, 1, 14]
(564) n=49392 Answer=[3, 0, 2, 4]
(565) n=50000 Answer=[0, 5, 0, 4]
(566) n=50176 Answer=[2, 0, 0, 10]
(567) n=50400 Answer=[1, 2, 2, 5]
(568) n=50421 Answer=[5, 0, 1, 0]
(569) n=50625 Answer=[0, 4, 4, 0]
(570) n=51030 Answer=[1, 1, 6, 1]
(571) n=51200 Answer=[0, 2, 0, 11]
(572) n=51450 Answer=[3, 2, 1, 1]
(573) n=51840 Answer=[0, 1, 4, 7]
(574) n=52488 Answer=[0, 0, 8, 3]
(575) n=52500 Answer=[1, 4, 1, 2]
(576) n=52920 Answer=[2, 1, 3, 3]
(577) n=53760 Answer=[1, 1, 1, 9]
(578) n=54000 Answer=[0, 3, 3, 4]
(579) n=54432 Answer=[1, 0, 5, 5]
(580) n=54675 Answer=[0, 2, 7, 0]
(581) n=54880 Answer=[3, 1, 0, 5]
(582) n=55125 Answer=[2, 3, 2, 0]
(583) n=55296 Answer=[0, 0, 3, 11]
(584) n=55566 Answer=[3, 0, 4, 1]
(585) n=56000 Answer=[1, 3, 0, 6]
(586) n=56250 Answer=[0, 5, 2, 1]
(587) n=56448 Answer=[2, 0, 2, 7]
(588) n=56700 Answer=[1, 2, 4, 2]
(589) n=57344 Answer=[1, 0, 0, 13]
(590) n=57600 Answer=[0, 2, 2, 8]
(591) n=57624 Answer=[4, 0, 1, 3]
(592) n=58320 Answer=[0, 1, 6, 4]
(593) n=58800 Answer=[2, 2, 1, 4]
(594) n=59049 Answer=[0, 0, 10, 0]
(595) n=59535 Answer=[2, 1, 5, 0]
(596) n=60000 Answer=[0, 4, 1, 5]
(597) n=60025 Answer=[4, 2, 0, 0]
(598) n=60480 Answer=[1, 1, 3, 6]
(599) n=60750 Answer=[0, 3, 5, 1]
(600) n=61236 Answer=[1, 0, 7, 2]
(601) n=61250 Answer=[2, 4, 0, 1]
(602) n=61440 Answer=[0, 1, 1, 12]
(603) n=61740 Answer=[3, 1, 2, 2]
(604) n=62208 Answer=[0, 0, 5, 8]
(605) n=62500 Answer=[0, 6, 0, 2]
(606) n=62720 Answer=[2, 1, 0, 8]
(607) n=63000 Answer=[1, 3, 2, 3]
(608) n=63504 Answer=[2, 0, 4, 4]
(609) n=64000 Answer=[0, 3, 0, 9]
(610) n=64512 Answer=[1, 0, 2, 10]
(611) n=64800 Answer=[0, 2, 4, 5]
(612) n=64827 Answer=[4, 0, 3, 0]
(613) n=65536 Answer=[0, 0, 0, 16]
(614) n=65610 Answer=[0, 1, 8, 1]
(615) n=65625 Answer=[1, 5, 1, 0]
(616) n=65856 Answer=[3, 0, 1, 6]
(617) n=66150 Answer=[2, 2, 3, 1]
(618) n=67200 Answer=[1, 2, 1, 7]
(619) n=67228 Answer=[5, 0, 0, 2]
(620) n=67500 Answer=[0, 4, 3, 2]
(621) n=68040 Answer=[1, 1, 5, 3]
(622) n=68600 Answer=[3, 2, 0, 3]
(623) n=69120 Answer=[0, 1, 3, 9]
(624) n=69984 Answer=[0, 0, 7, 5]
(625) n=70000 Answer=[1, 4, 0, 4]
(626) n=70560 Answer=[2, 1, 2, 5]
(627) n=70875 Answer=[1, 3, 4, 0]
(628) n=71442 Answer=[2, 0, 6, 1]
(629) n=71680 Answer=[1, 1, 0, 11]
(630) n=72000 Answer=[0, 3, 2, 6]
(631) n=72030 Answer=[4, 1, 1, 1]
(632) n=72576 Answer=[1, 0, 4, 7]
(633) n=72900 Answer=[0, 2, 6, 2]
(634) n=73500 Answer=[2, 3, 1, 2]
(635) n=73728 Answer=[0, 0, 2, 13]
(636) n=74088 Answer=[3, 0, 3, 3]
(637) n=75000 Answer=[0, 5, 1, 3]
(638) n=75264 Answer=[2, 0, 1, 9]
(639) n=75600 Answer=[1, 2, 3, 4]
(640) n=76545 Answer=[1, 1, 7, 0]
(641) n=76800 Answer=[0, 2, 1, 10]
(642) n=76832 Answer=[4, 0, 0, 5]
(643) n=77175 Answer=[3, 2, 2, 0]
(644) n=77760 Answer=[0, 1, 5, 6]
(645) n=78125 Answer=[0, 7, 0, 0]
(646) n=78400 Answer=[2, 2, 0, 6]
(647) n=78732 Answer=[0, 0, 9, 2]
(648) n=78750 Answer=[1, 4, 2, 1]
(649) n=79380 Answer=[2, 1, 4, 2]
(650) n=80000 Answer=[0, 4, 0, 7]
(651) n=80640 Answer=[1, 1, 2, 8]
(652) n=81000 Answer=[0, 3, 4, 3]
(653) n=81648 Answer=[1, 0, 6, 4]
(654) n=81920 Answer=[0, 1, 0, 14]
(655) n=82320 Answer=[3, 1, 1, 4]
(656) n=82944 Answer=[0, 0, 4, 10]
(657) n=83349 Answer=[3, 0, 5, 0]
(658) n=84000 Answer=[1, 3, 1, 5]
(659) n=84035 Answer=[5, 1, 0, 0]
(660) n=84375 Answer=[0, 5, 3, 0]
(661) n=84672 Answer=[2, 0, 3, 6]
(662) n=85050 Answer=[1, 2, 5, 1]
(663) n=85750 Answer=[3, 3, 0, 1]
(664) n=86016 Answer=[1, 0, 1, 12]
(665) n=86400 Answer=[0, 2, 3, 7]
(666) n=86436 Answer=[4, 0, 2, 2]
(667) n=87480 Answer=[0, 1, 7, 3]
(668) n=87500 Answer=[1, 5, 0, 2]
(669) n=87808 Answer=[3, 0, 0, 8]
(670) n=88200 Answer=[2, 2, 2, 3]
(671) n=89600 Answer=[1, 2, 0, 9]
(672) n=90000 Answer=[0, 4, 2, 4]
(673) n=90720 Answer=[1, 1, 4, 5]
(674) n=91125 Answer=[0, 3, 6, 0]
(675) n=91854 Answer=[1, 0, 8, 1]
(676) n=91875 Answer=[2, 4, 1, 0]
(677) n=92160 Answer=[0, 1, 2, 11]
(678) n=92610 Answer=[3, 1, 3, 1]
(679) n=93312 Answer=[0, 0, 6, 7]
(680) n=93750 Answer=[0, 6, 1, 1]
(681) n=94080 Answer=[2, 1, 1, 7]
(682) n=94500 Answer=[1, 3, 3, 2]
(683) n=95256 Answer=[2, 0, 5, 3]
(684) n=96000 Answer=[0, 3, 1, 8]
(685) n=96040 Answer=[4, 1, 0, 3]
(686) n=96768 Answer=[1, 0, 3, 9]
(687) n=97200 Answer=[0, 2, 5, 4]
(688) n=98000 Answer=[2, 3, 0, 4]
(689) n=98304 Answer=[0, 0, 1, 15]
(690) n=98415 Answer=[0, 1, 9, 0]
(691) n=98784 Answer=[3, 0, 2, 5]
(692) n=99225 Answer=[2, 2, 4, 0]
(693) n=100000 Answer=[0, 5, 0, 5]
(694) n=100352 Answer=[2, 0, 0, 11]
(695) n=100800 Answer=[1, 2, 2, 6]
(696) n=100842 Answer=[5, 0, 1, 1]
(697) n=101250 Answer=[0, 4, 4, 1]
(698) n=102060 Answer=[1, 1, 6, 2]
(699) n=102400 Answer=[0, 2, 0, 12]
(700) n=102900 Answer=[3, 2, 1, 2]
(701) n=103680 Answer=[0, 1, 4, 8]
(702) n=104976 Answer=[0, 0, 8, 4]
(703) n=105000 Answer=[1, 4, 1, 3]
(704) n=105840 Answer=[2, 1, 3, 4]
(705) n=107163 Answer=[2, 0, 7, 0]
(706) n=107520 Answer=[1, 1, 1, 10]
(707) n=108000 Answer=[0, 3, 3, 5]
(708) n=108045 Answer=[4, 1, 2, 0]
(709) n=108864 Answer=[1, 0, 5, 6]
(710) n=109350 Answer=[0, 2, 7, 1]
(711) n=109375 Answer=[1, 6, 0, 0]
(712) n=109760 Answer=[3, 1, 0, 6]
(713) n=110250 Answer=[2, 3, 2, 1]
(714) n=110592 Answer=[0, 0, 3, 12]
(715) n=111132 Answer=[3, 0, 4, 2]
(716) n=112000 Answer=[1, 3, 0, 7]
(717) n=112500 Answer=[0, 5, 2, 2]
(718) n=112896 Answer=[2, 0, 2, 8]
(719) n=113400 Answer=[1, 2, 4, 3]
(720) n=114688 Answer=[1, 0, 0, 14]
(721) n=115200 Answer=[0, 2, 2, 9]
(722) n=115248 Answer=[4, 0, 1, 4]
(723) n=116640 Answer=[0, 1, 6, 5]
(724) n=117600 Answer=[2, 2, 1, 5]
(725) n=117649 Answer=[6, 0, 0, 0]
(726) n=118098 Answer=[0, 0, 10, 1]
(727) n=118125 Answer=[1, 4, 3, 0]
(728) n=119070 Answer=[2, 1, 5, 1]
(729) n=120000 Answer=[0, 4, 1, 6]
(730) n=120050 Answer=[4, 2, 0, 1]
(731) n=120960 Answer=[1, 1, 3, 7]
(732) n=121500 Answer=[0, 3, 5, 2]
(733) n=122472 Answer=[1, 0, 7, 3]
(734) n=122500 Answer=[2, 4, 0, 2]
(735) n=122880 Answer=[0, 1, 1, 13]
(736) n=123480 Answer=[3, 1, 2, 3]
(737) n=124416 Answer=[0, 0, 5, 9]
(738) n=125000 Answer=[0, 6, 0, 3]
(739) n=125440 Answer=[2, 1, 0, 9]
(740) n=126000 Answer=[1, 3, 2, 4]
(741) n=127008 Answer=[2, 0, 4, 5]
(742) n=127575 Answer=[1, 2, 6, 0]
(743) n=128000 Answer=[0, 3, 0, 10]
(744) n=128625 Answer=[3, 3, 1, 0]
(745) n=129024 Answer=[1, 0, 2, 11]
(746) n=129600 Answer=[0, 2, 4, 6]
(747) n=129654 Answer=[4, 0, 3, 1]
(748) n=131072 Answer=[0, 0, 0, 17]
(749) n=131220 Answer=[0, 1, 8, 2]
(750) n=131250 Answer=[1, 5, 1, 1]
(751) n=131712 Answer=[3, 0, 1, 7]
(752) n=132300 Answer=[2, 2, 3, 2]
(753) n=134400 Answer=[1, 2, 1, 8]
(754) n=134456 Answer=[5, 0, 0, 3]
(755) n=135000 Answer=[0, 4, 3, 3]
(756) n=136080 Answer=[1, 1, 5, 4]
(757) n=137200 Answer=[3, 2, 0, 4]
(758) n=137781 Answer=[1, 0, 9, 0]
(759) n=138240 Answer=[0, 1, 3, 10]
(760) n=138915 Answer=[3, 1, 4, 0]
(761) n=139968 Answer=[0, 0, 7, 6]
(762) n=140000 Answer=[1, 4, 0, 5]
(763) n=140625 Answer=[0, 6, 2, 0]
(764) n=141120 Answer=[2, 1, 2, 6]
(765) n=141750 Answer=[1, 3, 4, 1]
(766) n=142884 Answer=[2, 0, 6, 2]
(767) n=143360 Answer=[1, 1, 0, 12]
(768) n=144000 Answer=[0, 3, 2, 7]
(769) n=144060 Answer=[4, 1, 1, 2]
(770) n=145152 Answer=[1, 0, 4, 8]
(771) n=145800 Answer=[0, 2, 6, 3]
(772) n=147000 Answer=[2, 3, 1, 3]
(773) n=147456 Answer=[0, 0, 2, 14]
(774) n=148176 Answer=[3, 0, 3, 4]
(775) n=150000 Answer=[0, 5, 1, 4]
(776) n=150528 Answer=[2, 0, 1, 10]
(777) n=151200 Answer=[1, 2, 3, 5]
(778) n=151263 Answer=[5, 0, 2, 0]
(779) n=151875 Answer=[0, 4, 5, 0]
(780) n=153090 Answer=[1, 1, 7, 1]
(781) n=153125 Answer=[2, 5, 0, 0]
(782) n=153600 Answer=[0, 2, 1, 11]
(783) n=153664 Answer=[4, 0, 0, 6]
(784) n=154350 Answer=[3, 2, 2, 1]
(785) n=155520 Answer=[0, 1, 5, 7]
(786) n=156250 Answer=[0, 7, 0, 1]
(787) n=156800 Answer=[2, 2, 0, 7]
(788) n=157464 Answer=[0, 0, 9, 3]
(789) n=157500 Answer=[1, 4, 2, 2]
(790) n=158760 Answer=[2, 1, 4, 3]
(791) n=160000 Answer=[0, 4, 0, 8]
(792) n=161280 Answer=[1, 1, 2, 9]
(793) n=162000 Answer=[0, 3, 4, 4]
(794) n=163296 Answer=[1, 0, 6, 5]
(795) n=163840 Answer=[0, 1, 0, 15]
(796) n=164025 Answer=[0, 2, 8, 0]
(797) n=164640 Answer=[3, 1, 1, 5]
(798) n=165375 Answer=[2, 3, 3, 0]
(799) n=165888 Answer=[0, 0, 4, 11]
(800) n=166698 Answer=[3, 0, 5, 1]
(801) n=168000 Answer=[1, 3, 1, 6]
(802) n=168070 Answer=[5, 1, 0, 1]
(803) n=168750 Answer=[0, 5, 3, 1]
(804) n=169344 Answer=[2, 0, 3, 7]
(805) n=170100 Answer=[1, 2, 5, 2]
(806) n=171500 Answer=[3, 3, 0, 2]
(807) n=172032 Answer=[1, 0, 1, 13]
(808) n=172800 Answer=[0, 2, 3, 8]
(809) n=172872 Answer=[4, 0, 2, 3]
(810) n=174960 Answer=[0, 1, 7, 4]
(811) n=175000 Answer=[1, 5, 0, 3]
(812) n=175616 Answer=[3, 0, 0, 9]
(813) n=176400 Answer=[2, 2, 2, 4]
(814) n=177147 Answer=[0, 0, 11, 0]
(815) n=178605 Answer=[2, 1, 6, 0]
(816) n=179200 Answer=[1, 2, 0, 10]
(817) n=180000 Answer=[0, 4, 2, 5]
(818) n=180075 Answer=[4, 2, 1, 0]
(819) n=181440 Answer=[1, 1, 4, 6]
(820) n=182250 Answer=[0, 3, 6, 1]
(821) n=183708 Answer=[1, 0, 8, 2]
(822) n=183750 Answer=[2, 4, 1, 1]
(823) n=184320 Answer=[0, 1, 2, 12]
(824) n=185220 Answer=[3, 1, 3, 2]
(825) n=186624 Answer=[0, 0, 6, 8]
(826) n=187500 Answer=[0, 6, 1, 2]
(827) n=188160 Answer=[2, 1, 1, 8]
(828) n=189000 Answer=[1, 3, 3, 3]
(829) n=190512 Answer=[2, 0, 5, 4]
(830) n=192000 Answer=[0, 3, 1, 9]
(831) n=192080 Answer=[4, 1, 0, 4]
(832) n=193536 Answer=[1, 0, 3, 10]
(833) n=194400 Answer=[0, 2, 5, 5]
(834) n=194481 Answer=[4, 0, 4, 0]
(835) n=196000 Answer=[2, 3, 0, 5]
(836) n=196608 Answer=[0, 0, 1, 16]
(837) n=196830 Answer=[0, 1, 9, 1]
(838) n=196875 Answer=[1, 5, 2, 0]
(839) n=197568 Answer=[3, 0, 2, 6]
(840) n=198450 Answer=[2, 2, 4, 1]
(841) n=200000 Answer=[0, 5, 0, 6]
(842) n=200704 Answer=[2, 0, 0, 12]
(843) n=201600 Answer=[1, 2, 2, 7]
(844) n=201684 Answer=[5, 0, 1, 2]
(845) n=202500 Answer=[0, 4, 4, 2]
(846) n=204120 Answer=[1, 1, 6, 3]
(847) n=204800 Answer=[0, 2, 0, 13]
(848) n=205800 Answer=[3, 2, 1, 3]
(849) n=207360 Answer=[0, 1, 4, 9]
(850) n=209952 Answer=[0, 0, 8, 5]
(851) n=210000 Answer=[1, 4, 1, 4]
(852) n=211680 Answer=[2, 1, 3, 5]
(853) n=212625 Answer=[1, 3, 5, 0]
(854) n=214326 Answer=[2, 0, 7, 1]
(855) n=214375 Answer=[3, 4, 0, 0]
(856) n=215040 Answer=[1, 1, 1, 11]
(857) n=216000 Answer=[0, 3, 3, 6]
(858) n=216090 Answer=[4, 1, 2, 1]
(859) n=217728 Answer=[1, 0, 5, 7]
(860) n=218700 Answer=[0, 2, 7, 2]
(861) n=218750 Answer=[1, 6, 0, 1]
(862) n=219520 Answer=[3, 1, 0, 7]
(863) n=220500 Answer=[2, 3, 2, 2]
(864) n=221184 Answer=[0, 0, 3, 13]
(865) n=222264 Answer=[3, 0, 4, 3]
(866) n=224000 Answer=[1, 3, 0, 8]
(867) n=225000 Answer=[0, 5, 2, 3]
(868) n=225792 Answer=[2, 0, 2, 9]
(869) n=226800 Answer=[1, 2, 4, 4]
(870) n=229376 Answer=[1, 0, 0, 15]
(871) n=229635 Answer=[1, 1, 8, 0]
(872) n=230400 Answer=[0, 2, 2, 10]
(873) n=230496 Answer=[4, 0, 1, 5]
(874) n=231525 Answer=[3, 2, 3, 0]
(875) n=233280 Answer=[0, 1, 6, 6]
(876) n=234375 Answer=[0, 7, 1, 0]
(877) n=235200 Answer=[2, 2, 1, 6]
(878) n=235298 Answer=[6, 0, 0, 1]
(879) n=236196 Answer=[0, 0, 10, 2]
(880) n=236250 Answer=[1, 4, 3, 1]
(881) n=238140 Answer=[2, 1, 5, 2]
(882) n=240000 Answer=[0, 4, 1, 7]
(883) n=240100 Answer=[4, 2, 0, 2]
(884) n=241920 Answer=[1, 1, 3, 8]
(885) n=243000 Answer=[0, 3, 5, 3]
(886) n=244944 Answer=[1, 0, 7, 4]
(887) n=245000 Answer=[2, 4, 0, 3]
(888) n=245760 Answer=[0, 1, 1, 14]
(889) n=246960 Answer=[3, 1, 2, 4]
(890) n=248832 Answer=[0, 0, 5, 10]
(891) n=250000 Answer=[0, 6, 0, 4]
(892) n=250047 Answer=[3, 0, 6, 0]
(893) n=250880 Answer=[2, 1, 0, 10]
(894) n=252000 Answer=[1, 3, 2, 5]
(895) n=252105 Answer=[5, 1, 1, 0]
(896) n=253125 Answer=[0, 5, 4, 0]
(897) n=254016 Answer=[2, 0, 4, 6]
(898) n=255150 Answer=[1, 2, 6, 1]
(899) n=256000 Answer=[0, 3, 0, 11]
(900) n=257250 Answer=[3, 3, 1, 1]
(901) n=258048 Answer=[1, 0, 2, 12]
(902) n=259200 Answer=[0, 2, 4, 7]
(903) n=259308 Answer=[4, 0, 3, 2]
(904) n=262144 Answer=[0, 0, 0, 18]
(905) n=262440 Answer=[0, 1, 8, 3]
(906) n=262500 Answer=[1, 5, 1, 2]
(907) n=263424 Answer=[3, 0, 1, 8]
(908) n=264600 Answer=[2, 2, 3, 3]
(909) n=268800 Answer=[1, 2, 1, 9]
(910) n=268912 Answer=[5, 0, 0, 4]
(911) n=270000 Answer=[0, 4, 3, 4]
(912) n=272160 Answer=[1, 1, 5, 5]
(913) n=273375 Answer=[0, 3, 7, 0]
(914) n=274400 Answer=[3, 2, 0, 5]
(915) n=275562 Answer=[1, 0, 9, 1]
(916) n=275625 Answer=[2, 4, 2, 0]
(917) n=276480 Answer=[0, 1, 3, 11]
(918) n=277830 Answer=[3, 1, 4, 1]
(919) n=279936 Answer=[0, 0, 7, 7]
(920) n=280000 Answer=[1, 4, 0, 6]
(921) n=281250 Answer=[0, 6, 2, 1]
(922) n=282240 Answer=[2, 1, 2, 7]
(923) n=283500 Answer=[1, 3, 4, 2]
(924) n=285768 Answer=[2, 0, 6, 3]
(925) n=286720 Answer=[1, 1, 0, 13]
(926) n=288000 Answer=[0, 3, 2, 8]
(927) n=288120 Answer=[4, 1, 1, 3]
(928) n=290304 Answer=[1, 0, 4, 9]
(929) n=291600 Answer=[0, 2, 6, 4]
(930) n=294000 Answer=[2, 3, 1, 4]
(931) n=294912 Answer=[0, 0, 2, 15]
(932) n=295245 Answer=[0, 1, 10, 0]
(933) n=296352 Answer=[3, 0, 3, 5]
(934) n=297675 Answer=[2, 2, 5, 0]
(935) n=300000 Answer=[0, 5, 1, 5]
(936) n=300125 Answer=[4, 3, 0, 0]
(937) n=301056 Answer=[2, 0, 1, 11]
(938) n=302400 Answer=[1, 2, 3, 6]
(939) n=302526 Answer=[5, 0, 2, 1]
(940) n=303750 Answer=[0, 4, 5, 1]
(941) n=306180 Answer=[1, 1, 7, 2]
(942) n=306250 Answer=[2, 5, 0, 1]
(943) n=307200 Answer=[0, 2, 1, 12]
(944) n=307328 Answer=[4, 0, 0, 7]
(945) n=308700 Answer=[3, 2, 2, 2]
(946) n=311040 Answer=[0, 1, 5, 8]
(947) n=312500 Answer=[0, 7, 0, 2]
(948) n=313600 Answer=[2, 2, 0, 8]
(949) n=314928 Answer=[0, 0, 9, 4]
(950) n=315000 Answer=[1, 4, 2, 3]
(951) n=317520 Answer=[2, 1, 4, 4]
(952) n=320000 Answer=[0, 4, 0, 9]
(953) n=321489 Answer=[2, 0, 8, 0]
(954) n=322560 Answer=[1, 1, 2, 10]
(955) n=324000 Answer=[0, 3, 4, 5]
(956) n=324135 Answer=[4, 1, 3, 0]
(957) n=326592 Answer=[1, 0, 6, 6]
(958) n=327680 Answer=[0, 1, 0, 16]
(959) n=328050 Answer=[0, 2, 8, 1]
(960) n=328125 Answer=[1, 6, 1, 0]
(961) n=329280 Answer=[3, 1, 1, 6]
(962) n=330750 Answer=[2, 3, 3, 1]
(963) n=331776 Answer=[0, 0, 4, 12]
(964) n=333396 Answer=[3, 0, 5, 2]
(965) n=336000 Answer=[1, 3, 1, 7]
(966) n=336140 Answer=[5, 1, 0, 2]
(967) n=337500 Answer=[0, 5, 3, 2]
(968) n=338688 Answer=[2, 0, 3, 8]
(969) n=340200 Answer=[1, 2, 5, 3]
(970) n=343000 Answer=[3, 3, 0, 3]
(971) n=344064 Answer=[1, 0, 1, 14]
(972) n=345600 Answer=[0, 2, 3, 9]
(973) n=345744 Answer=[4, 0, 2, 4]
(974) n=349920 Answer=[0, 1, 7, 5]
(975) n=350000 Answer=[1, 5, 0, 4]
(976) n=351232 Answer=[3, 0, 0, 10]
(977) n=352800 Answer=[2, 2, 2, 5]
(978) n=352947 Answer=[6, 0, 1, 0]
(979) n=354294 Answer=[0, 0, 11, 1]
(980) n=354375 Answer=[1, 4, 4, 0]
(981) n=357210 Answer=[2, 1, 6, 1]
(982) n=358400 Answer=[1, 2, 0, 11]
(983) n=360000 Answer=[0, 4, 2, 6]
(984) n=360150 Answer=[4, 2, 1, 1]
(985) n=362880 Answer=[1, 1, 4, 7]
(986) n=364500 Answer=[0, 3, 6, 2]
(987) n=367416 Answer=[1, 0, 8, 3]
(988) n=367500 Answer=[2, 4, 1, 2]
(989) n=368640 Answer=[0, 1, 2, 13]
(990) n=370440 Answer=[3, 1, 3, 3]
(991) n=373248 Answer=[0, 0, 6, 9]
(992) n=375000 Answer=[0, 6, 1, 3]
(993) n=376320 Answer=[2, 1, 1, 9]
(994) n=378000 Answer=[1, 3, 3, 4]
(995) n=381024 Answer=[2, 0, 5, 5]
(996) n=382725 Answer=[1, 2, 7, 0]
(997) n=384000 Answer=[0, 3, 1, 10]
(998) n=384160 Answer=[4, 1, 0, 5]
(999) n=385875 Answer=[3, 3, 2, 0]
(1000) n=387072 Answer=[1, 0, 3, 11]

kifuwarabe-futsu.png
「 👆 満足かだぜ、お父ん?」

ramen-tabero-futsu2.png
「 現代のパソコンでも 計算は1秒では終わらないんだなあ」

(0) n=1 Answer=[0, 0, 0, 0]
(9) n=10 Answer=[0, 1, 0, 1]
(45) n=100 Answer=[0, 2, 0, 2]
(140) n=1000 Answer=[0, 3, 0, 3]
(337) n=10000 Answer=[0, 4, 0, 4]
(693) n=100000 Answer=[0, 5, 0, 5]

ramen-tabero-futsu2.png
「 👆 10倍の価値の現れ方が 面白いよな?」

ohkina-hiyoko-futsu2.png
「 指数の底(てい)が 2 と 5 ですからねえ」

対数を使って、アルゴリズムを高速化しようぜ?

ramen-tabero-futsu2.png
「 n が 30万を超えてくると、割り切れる数を探すだけで 数秒かかってるしな……」

kifuwarabe-futsu.png
「 ベクトルの成分、 20 が出てくることも稀なのに 100 で回してるしな」

(904) n=262144 Answer=[0, 0, 0, 18]

ramen-tabero-futsu2.png
「 👆 例えば 2 の 18乗は 262144 だが、
底(てい)を2とする 262144 の対数は 18 だぜ。 log2 262144 = 18

ohkina-hiyoko-futsu2.png
「 ループする回数を、対数を使って 決めましょう」

# 素因数分解の練習
#
# cd math/prime_factorization
# python step1_1.py

import math

def factorize(n, debug=True):

    # int( ... ) だと、取りこぼしてしまうようだ。 math.ceil( ... ) とした
    # + 1 が必要
    a_max = math.ceil(math.log(n, 7))+1
    b_max = math.ceil(math.log(n, 5))+1
    c_max = math.ceil(math.log(n, 3))+1
    d_max = math.ceil(math.log(n, 2))+1

    for a in reversed(range(0,a_max)):
        aa = 7 ** a

        # n 以下の小さな合成数 7a なら、とりあえず n から、それを引く
        if aa <= n:
            remain = n - aa

            if debug:
                print(f"(7x{a}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [a, 0, 0, 0]

            # 余った数で続きをやる

            for b in reversed(range(0,b_max)):
                bb = aa * 5 ** b

                if bb <= n:
                    remain = n - bb

                    if debug:
                        print(f"\t(7x{a} x 5x{b}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [a, b, 0, 0]

                    # 余った数で続きをやる

                    for c in reversed(range(0,c_max)):
                        cc = bb * 3 ** c

                        if cc <= n:
                            remain = n - cc

                            if debug:
                                print(f"\t\t(7x{a} x 5x{b} x 3x{c}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [a, b, c, 0]

                            # 余った数で続きをやる

                            for d in reversed(range(0,d_max)):
                                dd = cc * 2 ** d

                                if dd <= n:
                                    remain = n - dd

                                    if debug:
                                        print(f"\t\t\t(7x{a} x 5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                                    # 割り切れた
                                    if remain == 0:
                                        return [a, b, c, d]


if __name__ == "__main__":

    print("""\
ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。
""")

    print("Please input number:")
    n = int(input())

    print(f"Anser:{factorize(n)}")

ramen-tabero-futsu2.png
「 👆 だいぶ速くなったけど、まだ遅い。一瞬で終わってほしいぜ」

kifuwarabe-futsu.png
「 累乗が遅くないか? 最初に a_max を指数にして累乗を求めて、 ループの終わりで 7 で割っていったらどうだぜ?」

ramen-tabero-futsu2.png
「 速度を比較してみるか。 Python で ストップウォッチの書き方は?」

📖 How to start stopwatch in python [duplicate]

import time

start = time.time()
# &lt;code to time&gt;
end = time.time()

print(f"Time taken to run the code was {end-start} seconds")

ramen-tabero-futsu2.png
「 よっしゃ」

# 素因数分解の練習
#
# cd math/prime_factorization
# python step3_0.py

import time
#from step1 import factorize
from step1_1_0 import factorize
#from step1_2_0 import factorize


start = time.time()
n = 1

for i in range(0,1001):
    # 答えが出るまで繰り返す
    while True:
        answer = factorize(n, debug=False)

        if answer is not None:
            print(f"({i}) n={n} Answer={answer}")

        n += 1

        if answer is not None:
            break

end = time.time()
print(f"Time: {end-start} seconds")

ramen-tabero-futsu2.png
「 👆 これで時間計測だ。さっきのソースは Time: 108.6974413394928 seconds だった」

# 素因数分解の練習
#
# cd math/prime_factorization
# python step1_2_0.py

import math

def factorize(n, debug=True):

    # int( ... ) だと、取りこぼしてしまうようだ。 math.ceil( ... ) とした
    # + 1 が必要
    a_max = math.ceil(math.log(n, 7))+1
    b_max = math.ceil(math.log(n, 5))+1
    c_max = math.ceil(math.log(n, 3))+1
    d_max = math.ceil(math.log(n, 2))+1

    aa = 7 ** a_max
    for a in reversed(range(0,a_max)):
        aa /= 7

        # n 以下の小さな合成数 7a なら、とりあえず n から、それを引く
        if aa <= n:
            remain = n - aa

            if debug:
                print(f"(7x{a}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [a, 0, 0, 0]

            # 余った数で続きをやる

            bb = 5 ** b_max
            for b in reversed(range(0,b_max)):
                bb /= 5
                aabb = aa * bb

                if aabb <= n:
                    remain = n - aabb

                    if debug:
                        print(f"\t(7x{a} x 5x{b}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [a, b, 0, 0]

                    # 余った数で続きをやる

                    cc = 3 ** c_max
                    for c in reversed(range(0,c_max)):
                        cc /= 3
                        aabbcc = aabb * cc

                        if aabbcc <= n:
                            remain = n - aabbcc

                            if debug:
                                print(f"\t\t(7x{a} x 5x{b} x 3x{c}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [a, b, c, 0]

                            # 余った数で続きをやる

                            dd = 2 ** d_max
                            for d in reversed(range(0,d_max)):
                                dd /= 2
                                aabbccdd = aabbcc * dd

                                if aabbccdd <= n:
                                    remain = n - aabbccdd

                                    if debug:
                                        print(f"\t\t\t(7x{a} x 5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                                    # 割り切れた
                                    if remain == 0:
                                        return [a, b, c, d]


if __name__ == "__main__":

    print("""\
ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。
""")

    print("Please input number:")
    n = int(input())

    print(f"Anser:{factorize(n)}")

ramen-tabero-futsu2.png
「 👆 このソースは Time: 138.23809385299683 seconds、 遅くなってるなあ」

kifuwarabe-futsu.png
「 状態なんか持ったら 遅いか」

# 素因数分解の練習
#
# cd math/prime_factorization
# python step1_1_1_0.py

import math

def factorize(n, debug=True):

    # int( ... ) だと、取りこぼしてしまうようだ。 math.ceil( ... ) とした
    # + 1 が必要
    a_max = math.ceil(math.log(n, 7))+1
    b_max = math.ceil(math.log(n, 5))+1
    c_max = math.ceil(math.log(n, 3))+1
    d_max = math.ceil(math.log(n, 2))+1

    reversed_a_list = list(reversed(range(0,a_max)))
    reversed_b_list = list(reversed(range(0,b_max)))
    reversed_c_list = list(reversed(range(0,c_max)))
    reversed_d_list = list(reversed(range(0,d_max)))

    for a in reversed_a_list:
        aa = 7 ** a

        # n 以下の小さな合成数 7a なら、とりあえず n から、それを引く
        if aa <= n:
            remain = n - aa

            if debug:
                print(f"(7x{a}) remain:{remain}")

            # 割り切れた
            if remain == 0:
                return [a, 0, 0, 0]

            # 余った数で続きをやる

            for b in reversed_b_list:
                bb = aa * 5 ** b

                if bb <= n:
                    remain = n - bb

                    if debug:
                        print(f"\t(7x{a} x 5x{b}) remain:{remain}")

                    # 割り切れた
                    if remain == 0:
                        return [a, b, 0, 0]

                    # 余った数で続きをやる

                    for c in reversed_c_list:
                        cc = bb * 3 ** c

                        if cc <= n:
                            remain = n - cc

                            if debug:
                                print(f"\t\t(7x{a} x 5x{b} x 3x{c}) remain:{remain}")

                            # 割り切れた
                            if remain == 0:
                                return [a, b, c, 0]

                            # 余った数で続きをやる

                            for d in reversed_d_list:
                                dd = cc * 2 ** d

                                if dd <= n:
                                    remain = n - dd

                                    if debug:
                                        print(f"\t\t\t(7x{a} x 5x{b} x 3x{c} x 2x{d}) remain:{remain}")

                                    # 割り切れた
                                    if remain == 0:
                                        return [a, b, c, d]


if __name__ == "__main__":

    print("""\
ある正の整数 n があるとする。
とりあえず n は 1~100 ぐらいを考えておく。

n を 2, 3, 5, 7 の素数で素因数分解する。

答えがいくつかあるとき、大きな数を多く使ったものを 1つ 選ぶことにする。
""")

    print("Please input number:")
    n = int(input())

    print(f"Anser:{factorize(n)}")

ramen-tabero-futsu2.png
「 👆 リストの作成を ループの外に出したら Time: 98.08642745018005 seconds 10秒速くなったぜ」

ohkina-hiyoko-futsu2.png
「 ビットコイン掘ってるみたいで 不毛な計算ねえ」

計算回そう

# 素因数分解の練習
#
# cd math/prime_factorization
# python step3_1_0.py

import time
#from step1 import factorize
#from step1_1_0 import factorize
from step1_1_1_0 import factorize # これが高速
#from step1_2_0 import factorize

print("Start")

start = time.time()
n = 1

with open('data_time.txt', mode='w') as f_t:
    with open('data.txt', mode='w') as f:

        f.write("""\
     i,          n,    7,    5,    3,    2
------, ----------, ----, ----, ----, ----
""")

        for i in range(0,1000001):
            # 答えが出るまで繰り返す
            while True:
                answer = factorize(n, debug=False)

                if answer is not None:
                    f.write(f"{i:6}, {n:10}, {answer[0]:4}, {answer[1]:4}, {answer[2]:4}, {answer[3]:4}\n")

                n += 1

                if answer is not None:
                    break

            # 100件ごとにタイムを入れる
            if i % 100 == 0:
                end = time.time()
                f_t.write(f"# (i={i}) Time: {end-start} seconds\n")
                f_t.flush()     # バッファーが溜まると書き出されるが、とりあえず毎回書きだす

        end = time.time()
        f_t.write(f"# (Finished) Time: {end-start} seconds\n")

print("Finished")

ramen-tabero-futsu2.png
「 👆 出力は、CSV フォーマットにしよ」

ramen-tabero-futsu2.png
「 終わったら、テキストファイルに保存したいな。
ログみたいに 垂れ流した方がいいか」

ramen-tabero-futsu2.png
「 処理時間も出力しよ」

ramen-tabero-futsu2.png
「 100万件 計算するようにして、 これを寝ている間に実行しようぜ?」

.

ツイッターでシェア
みんなに共有、忘れないようにメモ

むずでょ@きふわらべ第29回世界コンピューター将棋選手権一次予選36位

光速のアカウント凍結されちゃったんで……。ゲームプログラムを独習中なんだぜ☆電王戦IIに出た棋士もコンピューターもみんな好きだぜ☆▲(パソコン将棋)WCSC29一次予選36位、SDT5予選42位▲(パソコン囲碁)AI竜星戦予選16位

Crieitは誰でも投稿できるサービスです。 是非記事の投稿をお願いします。どんな軽い内容でも投稿できます。

また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!

有料記事を販売できるようになりました!

こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください。
ボードとは?

コメント