SDOI2013 Necklace Necklace

Source: Internet
Author: User
Tags greatest common divisor
Description

(Jzoj 3298)
There's a necklace of n-N beads
Each bead has 3 sides, can write 3 numbers, the range of numbers (0,a] (0,a], the two beads are the same when and only if they can be turned into the same
The three-digit greatest common divisor on each bead must be equal to 1
Two adjacent beads must be different
If two necklaces can be turned into the same, we think the two strings are the same.
Given n N and a A, how many different necklaces are asked. Answer to 1000000007 1000000007 modulo. Data Constraint

For data of 10 10%: n<=10,a<=10,t<=10 N;
For data of 20 20%: n<=1000,a<=100,t<=10 N;
For data of 40 40%: n<=109,a<=100,t<=10 N;
For data of 60 60%: n<=106,a<=105,t<=10 N;
For data of 80 80%: n<=109,a<=105,t<=10 N;
For data of 100 100%: n<=1014,a<=107,t<=10 N; solution

Ask for Bead type first

Useful only in order to
123 122 112 111
Numbers represent size relationships

111 There is only one
122 112 figure out 12 and.
123 count.

12:
Set F[i][a]

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.