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