Qingdao Race Training (number theory)

Source: Internet
Author: User
Qingdao Race Training A-fantasy of a summation LightOJ-1213 time: October 5 23 o'clock 30

Https://cn.vjudge.net/contest/258301#problem
The problem, test instructions gives is a K-cycle, each loop I weighs 1 to n, the loop body is res = (res + A[I1] + A[i2] + ... + a[ik])% MOD; The value of the last res.

Analysis: Combinatorial math + fast Power

Solution: For each a[i] is the same,
So we figure out the total a[i] The number of occurrences/n to know the number of occurrences
The total number of times is (n^k)K, so each occurrence (n^ (k-1))K
So the answer is sum(n^ (k-1))K%mod, which is finally solved with a fast power.

In the update ..... .....

Qingdao Race Training (number theory)

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.