Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- BigInteger[] arr = new BigInteger[1001];
- arr[1] = BigInteger.valueOf(0);
- arr[2] = BigInteger.valueOf(1);
- for(int i=3; i < 1001; i++){
- arr[i] = arr[i-1].multiply(BigInteger.valueOf(2));
- if(i % 2 == 0){
- arr[i] = arr[i].add(BigInteger.valueOf(1));
- }
- else{
- arr[i] = arr[i].subtract(BigInteger.valueOf(1));
- }
- }
- Scanner in = new Scanner(System.in);
- while(in.hasNext()){
- int b;
- b = in.nextInt();
- System.out.println(arr[b]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement