# "Openj_poj c16d" extracurricular Sports (construction, law-seeking)

Source: Internet
Author: User

Topic
n a different number to satisfy its LCM.
We take the LCM as a line segment and divide it into n parts of different lengths.
Of course there are a lot of different methods, we only need to construct a good to write.
Divide it into two one-second, take one of one-second and divide it into 1/3 and 2/3, and then each take 1/3 to 1/3 and 2/3.
1
1/2 1/2
1/2 2/6 1/6
1/2 2/6 2/18 1/18
The shortest is 1/18 of this, we make it 1. The other lengths can be calculated: 9 6 2 1.
So the shortest two, then each number is the sum of the preceding number twice times, the last number is the sum of all the preceding numbers.
A little longer: 1 2 6 18 54 81
It can be found that the first two numbers are 1, 2, followed by 3 times times the previous number, the last number is 3 n-2.
Make \$a[0]=1,a[i]=2*3^{i-1}\$ < Span class= "Mjx-char mjxc-tex-main-r" >< Span id= "mjxc-node-24" class= "Mjx-mo" > is written in a large integer class of Java and is relatively thin.

`Import java.io.*;import java.math.*;import java.util.*;p ublic class main{    //a[i]=1 2 6 162    static Bigintege R a[]=new biginteger[250];    public static void Main (string[] args) {        Scanner cin= new Scanner (system.in);        A[0]=biginteger.valueof (1);        A[1]=biginteger.valueof (2);        for (int i=2;i<=200;i++)            a[i]=a[i-1].multiply (biginteger.valueof (3));        int T=cin.nextint ();        for (int i=1;i<=t;i++) {            int n=cin.nextint ();            if (n==2) System.out.println ( -1);            else{for                (int j=0;j<n-1;j++)                    System.out.println (A[j]);                 System.out.println (A[n-1].divide (biginteger.valueof (2));}}}}    `

"Openj_poj c16d" extracurricular Sports (construction, law-seeking)

Related Keywords:

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.