My solution for CF 363 — F dvi1

Revision en2, by Lucas97, 2016-08-21 07:40:34

Hi guys, given that the tutorial didn't include any solution for problem F of that round, I decided to explain my solution because I'm sure the problem was really interesting.

First step

Let's denote f as the inverse map of p.

We can easily notice that the key is about looking at the prime factors of the numbers because the condition (i, j) = 1 iff (pi, pj) = 1 is equal to (i and j don't share any prime factor) iff (pi and pj don't share any prime factor). So, we will divide the numbers into some groups(which are not necessarily disjoint) such that any tow numbers in the same group share a common prime factor. Then, let Gq be the group of all numbers between 1 and n which are divisible by q. In addition, we will keep a group G1 = { 1 }, because as we know 1 is coprime with any number and it also doesn't have any prime factor.

Now, these groups are interesting because px and py will be in some group Gr for any numbers x and y in Gq (r depends on x and y, obviously). However, we could show that p(Gq) = Gr for any prime number q. The proof consists on noticing that if pq belongs to some group Gr then (f(r) , q) is not 1(because r and pq are in the same group) then f(r) belongs to Gq. Now, if y belongs to Gq then (y, x) is not 1 and then (py, r),so py belongs to Gr. Then, p(Gq) Gr. Analogously, we can prove that f(Gr) Gq and that completes the proof.(We used that q is prime, but this proof also works if q = 1).

So, we have proved that any q is mapped into some other r(where q and r are the indexes of the groups i.e. primes or 1). And this is basically all the solution because the next step will be about proving that if h is a bijective map which takes indexes into indexes of groups, then px = y is a feasible permutation , where all the prime factors of y are the images by h of the prime factors of x(here we are considering that the only factor of 1 is 1).

Second step

Claim: The only feasible permutations are those which satisfies px = y where all the prime factor of y are the images by h of the prime factors of x.

It is fairly easy to prove that if p satisfies the condition stated before, then p satisfies (i , j) = 1 iff (pi, pj) = 1

Now, we will prove that the condition is necessary. It is clear that h needs to be bijective(a group can only be mapped into one group).If q is any prime factor of x then h(q) is a prime factor of px(because of First Step). If r is any prime factor of y then the preimage of r is a prime factor of the preimage of px(This is also the first step, but considering the inverse of h instead of h). (Again, the proof remains true for the case q = 1).

Conclusion

In summary, we have proved that any bijective map h and any permutation satisfying Claim will turn out to be a feasible solution for p. So, the answer will be (#of feasible h)(# number of feasible p given h)

Number of feasible h is the number of ways to assign a prime r to any other prime q(here we will say 1 is "prime"), but those h are not only random bijective maps between primes, we should remember that the assignment satisfies that h(q) = r iff p(Gq) = Gr, so it is necessary that (number of elements of Gr) = (number of elements of Gq). Then, in the implementation, we will compute (number of elements of every group Gs) which is 1 if s = 1 and n/s if s is a prime greater than 1.(Think about it for a while if it's not clear at the beginning). Then, we should know how many groups have a fixed numbers of elements , say there are gr[t] groups which have t elements. Provided of this notation, the number of maps h will be

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English Lucas97 2016-08-21 10:01:41 21
en5 English Lucas97 2016-08-21 09:59:54 2 Tiny change: 'that any tow numbers i' -> 'that any two numbers i'
en4 English Lucas97 2016-08-21 09:42:04 20
en3 English Lucas97 2016-08-21 09:35:46 5274 Tiny change: 'rod\limits{t = 1}^ng' - (published)
en2 English Lucas97 2016-08-21 07:40:34 493 Tiny change: 'n h) \n\n#of feasibl' -
en1 English Lucas97 2016-08-21 07:27:51 3383 Initial revision (saved to drafts)