zoukankan      html  css  js  c++  java
  • HDU 1812 polya 大数

    由于反射的存在,分奇偶讨论其置换的循环节数量,大数用JAVA就好了。

    import java.math.*;
    import java.util.*;
    
    public class Main{
        public static void main(String[] args) {
            Scanner cin = new Scanner(System.in);
            int n, t;
            while(cin.hasNext()) {
                n = cin.nextInt();
                BigInteger c = cin.nextBigInteger();
                BigInteger sum = BigInteger.valueOf(0);
                if(n % 2 == 0)    {
                    sum = sum.add(c.pow(n * n));//0
                    sum = sum.add(c.pow(n * n / 4));//90
                    sum = sum.add(c.pow(n * n / 2));//180
                    sum = sum.add(c.pow(n * n / 4));//270
                    sum = sum.add(c.pow(n * (n - 1) / 2 + n));//mirC
                    sum = sum.add(c.pow(n * (n - 1) / 2 + n));//mirC
                    sum = sum.add(c.pow(n * n / 2));//mirM
                    sum = sum.add(c.pow(n * n / 2));//mirM
                }
                else{
                    sum = sum.add(c.pow(n * n));//0
                    sum = sum.add(c.pow((n * n - 1) / 4 + 1));//90
                    sum = sum.add(c.pow((n * n - 1) / 2 + 1));//180
                    sum = sum.add(c.pow((n * n - 1) / 4 + 1));//270
                    sum = sum.add(c.pow(n * (n + 1) / 2));//mirC
                    sum = sum.add(c.pow(n * (n + 1) / 2));//mirC
                    sum = sum.add(c.pow(n * (n + 1) / 2));//mirM
                    sum = sum.add(c.pow(n * (n + 1) / 2));//mirM
                }
                sum = sum.divide(BigInteger.valueOf(8));
                System.out.println(sum);
                
            }
        }
    }
    
  • 相关阅读:
    程序员励志语录
    javaEE的十一种技术
    gui内函数调用顺序
    m文件中函数的执行顺序
    VC++与Matlab混合编程之引擎操作详解(6)数据类型mxArray的操作
    GUI(2)
    时间管理
    Matlab GUI界面
    matlab GUI(2)
    MATLAB GUI平台
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/7554005.html
Copyright © 2011-2022 走看看