Bzoj 3288 Mato Matrix Problem Solving Report

Source: Internet
Author: User

This question is good God. Orz Taorunz

There is a conclusion that this conclusion feels very beautiful:

$ $ans = \prod_{i=1}^{n}\varphi (i) $$

As for why, this is probably the case:

For each number $x $, the $x $ line has $x-\varphi (x) $ number is not $1$, then this line is to be eliminated $x-\varphi (x) $ times (do not forget that each row will be $1$ to eliminate once), each elimination will make $A [x][x]$ minus one, so $A [x] [x]$ will eventually become $\varphi (x) $, so that's the answer.

The complexity of the time space is $O (n) $.

1#include <cstdio>2typedefLong LongLL;3 #defineN 1000000 + 54 #defineM 100000 + 55 #defineMod 10000000076 7 intN, ans =1, Phi[n], q[m];8 9 intMain ()Ten { Onescanf"%d", &n); A      for(inti =2; I <= N; i + +) -     { -         if(!Phi[i]) the         { -Phi[i] = i-1; -q[++ q[0]] =i; -         } +          for(intj =1; J <= q[0] && i * q[j] <= N; J + +) -         { +             if(i% q[j] = =0) A             { atPhi[i * Q[j]] = phi[i] *Q[j]; -                  Break ; -             } -Phi[i * Q[j]] = phi[i] *Phi[q[j]]; -         } -Ans = (LL) ans * phi[i]%Mod; in     } -printf"%d\n", ans); to     return 0; +}
3288_gromah

Bzoj 3288 Mato Matrix problem Solving report

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.