zoukankan      html  css  js  c++  java
  • hdoj2409

    /***************************************************************\
     *Author:Hu Wenbiao
     *Created Time: Mon 30 Aug 2010 08:53:42 PM CST
     *File Name: main.cpp
     *Description:polya定理
    \***************************************************************/
    //*========================*Head File*========================*\\
    
    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    #include<string.h>
    /*----------------------*Global Variable*----------------------*/
    
    //*=======================*Main Program*=======================*//
    
    int gcd(int a,int b){
     int tmp;
     while(b){
      tmp=a;
      a=b;
      b=tmp%b;
     }
     return a;
    }
    int fun(int t,int c,int s){
     int d=gcd(s,t);
     int ans=1;
     for(int i=0;i<d;i++)
       ans*=c;
     return ans;
    }
    int main(){
     //freopen("input","r",stdin);
     int c,s,ans;
     while(scanf("%d%d",&c,&s)!=EOF&&(c||s)){
      if(s&1){//odd
       ans=(pow(c,s)+s*pow(c,(s+1)>>1));
       for(int i=1;i<s;i++)
         ans+=fun(i,c,s);
       ans/=(s<<1);
      }
      else{//even
       if(s==2)
         ans=c*(c+1)>>1;
       else{
        ans=(pow(c,s)+(s>>1)*pow(c,(s+2)>>1)+(s>>1)*pow(c,s>>1));
        for(int i=1;i<s;i++)
          ans+=fun(i,c,s);
        ans/=(s<<1);
       }
    
      }
      printf("%d\n",ans);
     }
    }
    

  • 相关阅读:
    周总结14
    周总结13
    周总结12
    周总结11
    周总结10
    Pytorch实现GCN、GraphSAGE、GAT
    pytorch在损失函数中为权重添加L1正则化
    conda安装虚拟环境或者软件包时一直报错
    各种报错
    Pytorch-torchtext的使用
  • 原文地址:https://www.cnblogs.com/Open_Source/p/1904878.html
Copyright © 2011-2022 走看看