Http://acm.hdu.edu.cn/showproblem.php? Pid = 3547 questions about yesterday's competition; problems related to cube vertex dyeing

Source: Internet
Author: User
Http://acm.hdu.edu.cn/showproblem.php? Pid = 3547 yesterday's competition question; cube vertex dyeing question this question is cube vertex dyeing, part of the polya count: there is a formula for direct set, (k ^ 8 & #43; 17 * k ^ 4 & #43; 6 * k ^ 2)/24; where k represents the face http://acm.hdu.edu.cn/showproblem.php? Pid = 3547 yesterday's competition question; cube vertex dyeing problem

This is part of the vertex coloring of the cube, polya counting: there is a formula to set directly, (k ^ 8 + 17 * k ^ 4 + 6 * k ^ 2)/24; k indicates the number of colors. because the question is high precision, it is obvious that Java can be used. However, nbutOJ does not support direct ORZ... Then we started the sad reminder of wa ,,,,

import java.util.*;import java.math.*;import java.lang.*;public class Main {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stub Scanner cin=new Scanner(System.in); int t=cin.nextInt();for(int i=1;i<=t;i++) {       BigDecimal a=cin.nextBigDecimal(),b=BigDecimal.valueOf(24),c,d=BigDecimal.valueOf(17);                 c=(a.pow(8).add(d.multiply(a.pow(4))).add(BigDecimal.valueOf(6).multiply(a.pow(2)))).divide(b);          String str=c.toPlainString();     //  System.out.println("C==="+c+"  "+"str=="+str);       System.out.print("Case "+i+": ");          if(str.length()>15)          {          for(int j=str.length()-15;j
 
  

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.