このチャットの会話に触発された
充足数は、10進数表現が abx
の形式で、以下のプロパティを持つ数値です。
-
x
is the longest trailing repeating suffix, or the
last digit if there is no repetition at the end
(123333
->3333
,545656
->5656
,123
->
3
) -
b
is the single digit prior tox
(123333
->2
,55545656
->4
) -
a
is the remaining prefix (123333
->1
,55545656
->
555
) -
a == c**b
(**
denotes exponentation),
wherec
is the number of repetitions of the smallest
repeating portion ofx
(1623333
->
4
(3 3 3 3
, not33 33
))
たとえば、 a = 8
、 b = 3
、 c =
の
28300
x = 00
x = 1
、 b = 5
、 a = 246
、 24651
c ^ 5 = 246
を満たす整数 c
ではありません。 x =
と
222b = 1
では a
の数字は残っていないので、
1222
/code>
Given a positive integer n >= 100
, output
whether or not n
is a satisfying number.
例
8300: True (a=8, b=3, c=2, x=00)
24651: False
1222: False
92555: True (a=9, b=2, c=3, x=555)
64633: True (a=64, b=6, c=2, x=33)
512944: True (a=512, b=9, c=2, x=44)
123: True (a=1, b=2, c=1, x=3)
822809: False
376664: False
723799: False
1234: False
34330000000: True (a=343, b=3, c=7, x=0000000)
92313131: True (a=9, b=2, c=3, x=313131)
16424442444: True (a=16, b=4, c=2, x=24442444)
ベストアンサー
Jelly, 26 bytes
が長すぎると感じる
DŒṖṖEÐƤḄ$ÐṀLÐṂṪµḢ*@0¦LµṪ⁼Ḍ
整数をとり、入力が満足すれば 1
、そうでなければ 0
を返すモナドリンクです。
Try it
online! or see a test-suite
どうやって?
DŒṖṖEÐƤḄ$ÐṀLÐṂṪµḢ*@0¦LµṪ⁼Ḍ - Link: integer, n e.g. 8300
D - to decimal list [8,3,0,0]
ŒṖ - all partitions [[[8],[3],[0],[0]],[[8],[3],[0,0]],[[8],[3,0],[0]],[[8],[3,0,0]],[[8,3],[0],[0]],[[8,3],[0,0]],[[8,3,0],[0]],[[8,3,0,0]]]
Ṗ - pop (the "no tail" one) [[[8],[3],[0],[0]],[[8],[3],[0,0]],[[8],[3,0],[0]],[[8],[3,0,0]],[[8,3],[0],[0]],[[8,3],[0,0]],[[8,3,0],[0]]]
ÐṀ - keep maximal under the operation: e.g. for [[8,3],[0],[0]]
$ - last two links as a monad:
ÐƤ - for suffixes: i.e. [[[8,3],[0],[0]],[[0],[0]],[[0]]]
E - all equal? [0 ,1 ,1]
Ḅ - convert from binary 3
- ...which yields [[[8],[3],[0],[0]],[[8,3],[0],[0]]]
ÐṂ - keep minimal under the operation:
L - length
- ...which yields [[[8,3],[0],[0]]]
Ṫ - tail (rightmost) [[8,3],[0],[0]]
µ - monadic chain separation
Ḣ - yield head and modify [8,3] ...leaving [[0],[0]]
L - length (of modified) 2
¦ - sparse application (to the [8,3])
0 - ...to index: 0 (to the rightmost digit, the 3)
*@ - power ([email protected] args) [8,8] ([8, 3*@2] = [8, 2*3] = [8,8])
µ - monadic chain separation
Ṫ - yield tail and modify 8 ...leaving [8]
Ḍ - from decimal (modified) 8
⁼ - equal? 1