10213 How Many Pieces of Land?

Problem Link

Hints:

Using Combinatorics

nC4+nC2+1

 

#Solution

import java.util.*;
import java.math.*;

public class Main {

public static void main(String[] args)
{
long n;
BigDecimal a=new BigDecimal(“0”);

BigDecimal c=new BigDecimal(“0”);
BigDecimal b=new BigDecimal(“0”);
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
for(int i=0;i<n;i++)
{
a=sc.nextBigDecimal();
b=a.multiply(a.subtract(BigDecimal.valueOf(1)));
b=b.multiply(a.subtract(BigDecimal.valueOf(2)));
b=b.multiply(a.subtract(BigDecimal.valueOf(3)));
b=b.divide(BigDecimal.valueOf(24));
c=a.multiply(a.subtract(BigDecimal.valueOf(1)));
c=c.divide(BigDecimal.valueOf(2));
b=b.add(c);
b=b.add(BigDecimal.valueOf(1));
System.out.println(b.toString());

}
}
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized, uva and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s