Poj Solution 1405

http://poj.org/problem?id=1405

import java.io.BufferedInputStream;   
import java.math.BigDecimal;   
import java.util.ArrayList;   
import java.util.Scanner;   
public class Main {   
  
    public static void main(String[] args) {   
        Scanner scan = new Scanner(new BufferedInputStream(System.in));   
        if (scan.hasNext()) {   
            int n = scan.nextInt();   
            ArrayList<BigDecimal> results = new ArrayList(18);   
            results.add(0, new BigDecimal(2));   
            for (int i = 1; i < 18; i++) {   
                BigDecimal last = results.get(i - 1);   
                BigDecimal temp = (last.add(BigDecimal.ONE.negate())).multiply(last).add(BigDecimal.ONE);   
                results.add(i, temp);   
            }   
            for (int i = 1; i <= n; i++) {   
                System.out.println(results.get(i - 1));   
            }   
        }   
    }   
}  


											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *