对polya定理中循环节的理解:把相互变换的所有元素看成一组 , polya公式的次方项就是组数
一般对于手镯刚体变换模型只考虑旋转和翻转变换。
poj 2409
#include <stdio.h>
#include <math.h>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <math.h>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
using namespace std;
int main()
{
int c,s;
while(scanf("%d%d",&c,&s)&&(c||s))
{
long long ans=0;
for(int i=1;i<=s;i++)
{
ans+=pow(c,__gcd(s,i));
}
if(s%2==1)
{
ans+=s*pow(c,((s-1)/2+1));
}
else
{
ans+=(s/2)*pow(c,s/2);
ans+=(s/2)*pow(c,(s+2)/2);
}
printf("%lld\n",ans/(2*s));
}
return 0;
}
{
int c,s;
while(scanf("%d%d",&c,&s)&&(c||s))
{
long long ans=0;
for(int i=1;i<=s;i++)
{
ans+=pow(c,__gcd(s,i));
}
if(s%2==1)
{
ans+=s*pow(c,((s-1)/2+1));
}
else
{
ans+=(s/2)*pow(c,s/2);
ans+=(s/2)*pow(c,(s+2)/2);
}
printf("%lld\n",ans/(2*s));
}
return 0;
}
poj 1286
#include
<bits/stdc++.h>
using namespace std ;
int main ()
{
int n ;
while ( scanf ( "%d" ,&n )&&n !=- 1 )
{
long long ans = 0 ;
for ( int i = 1 ;i <=n ;i ++)
{ ans += pow ( 3 , __gcd (n ,i ));
}
if (n % 2 == 1 )
{
ans +=n * pow ( 3 ,((n -1 )/ 2+1 ));
}
else
{
ans +=(n / 2 )* pow ( 3 ,n / 2 );
ans +=(n / 2 )* pow ( 3 ,(n +2 )/ 2 );
}
printf ( "%lld \n " ,ans /( 2 *n ));
}
return 0 ;
}
using namespace std ;
int main ()
{
int n ;
while ( scanf ( "%d" ,&n )&&n !=- 1 )
{
long long ans = 0 ;
for ( int i = 1 ;i <=n ;i ++)
{ ans += pow ( 3 , __gcd (n ,i ));
}
if (n % 2 == 1 )
{
ans +=n * pow ( 3 ,((n -1 )/ 2+1 ));
}
else
{
ans +=(n / 2 )* pow ( 3 ,n / 2 );
ans +=(n / 2 )* pow ( 3 ,(n +2 )/ 2 );
}
printf ( "%lld \n " ,ans /( 2 *n ));
}
return 0 ;
}