Poj 2409 Let it Bead Polya count

Source: Internet
Author: User

Poj 2409 Let it Bead Polya count

Rotation can be divided into n replicas. The corresponding equivalence classes are gcd (n, I) I = 0, and n replicas exist.

The flip is divided into parity discussions. There are n replicas in an odd number, each of which has n/2 + 1

There are n replicas in an even number, with n/2 + 1 in half and n/2 in half.

I have been reading Polya theorem for a long time in my thesis, PPT, and various books. Recently I am seriously skeptical about my IQ when I am doing a math problem.

#include 
 
  #include 
  
   #include 
   
    #include#include
    #include
     
      using namespace std;typedef long long ll;ll gcd(ll a,ll b) {return a%b==0?b:gcd(b,a%b);}ll quickpow(ll m,ll n){    ll ans=1;    while(n)    {        if(n&1) ans=ans*m;        n=(n>>1);        m=m*m;    }    return ans;}int main(){    ll c,n;    while(~scanf("%lld%lld",&c,&n))    {        if(c+n==0) break;        ll ans=quickpow(c,n);        for(int i=1;i
      
       

Related Article

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.