*Answer*: (a) Miku; (b) Juku.
The positional representation with radix a consisting of n ones denotes the sum an−1+an−2+⋯+a+1 which equals a−1an−1.
a. Let a≡1(modp). If p>2 or a≡1(mod4) then, by the lifting-the-exponent lemma, the exponent of the prime p in the canonical representation of a−1an−1 equals that in the canonical representation of n. Thus to win, Miku may choose any number n that is divisible by p. If p=2 and a≡−1(mod4) then the exponent of the prime 2 in the canonical representation of a−1 is 1, while that in the canonical representation of a2−1 is larger as a2≡1(mod4). Thus to win, Miku may choose n=2.
Let now a≡1(modp). By Fermat's little theorem, ap−1≡1(modp). Hence an≡1(modp) whenever n is a multiple of p−1. Then the numerator of the fraction a−1an−1 is divisible by p while the denominator is not, whence the value of the fraction is divisible by p. Consequently, Miku can win by choosing any multiple of p−1 greater than 1 as n.
b. We show that Juku wins by choosing n=2p−1. Let a be the number chosen by Miku.
Let a≡1(modp). If p>2 or a≡1(mod4) then, by the lifting-the-exponent lemma, the exponent of p in the canonical representation of a−1an−1 equals that in the canonical representation of n. As p does not divide 2p−1, it does not divide a−1an−1 either. If p=2 and a≡−1(mod4) then an≡−1(mod4), whence 2 does not divide an−1. Therefore 2 does not divide a−1an−1.
Let now a≡1(modp). By Fermat's little theorem, ap−1≡1(modp) and ap≡a(modp), giving an=a2p−1≡a(modp). Thus an≡1(modp). As p does not divide the numerator of the fraction a−1an−1, it cannot divide the value of the fraction either.