uva 10523 Very Easy !!!

Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu

 Status

Description

Download as PDF

THE SAMS' CONTEST

Problem 4

 VERY EASY !!! 

BACKGROUND

Most of the times, the students of Computer Science & Engineering of BUET deal with bogus, tough and very complex formulae. That is why, sometimes, even for a easy problem they think very hard and make the problem much complex to solve. But, the team members of the team "BUET PESSIMISTIC"  are the only exceptions. Just like the opposite manner, they treat every hard problem as easy and so cannot do well in any contest. Today, they try to solve a series but fail for treating it as hard. Let them help.

Input

Just try to determine the answer for the following series

You are given the value of and A (integer, 1<=N<=150  &  integer, 0<=A<=15) respectively.

Output

For each line of the input, your correct program should output the integer value of the sum in separate lines for each pair of values of N & A.

Sample Input

3 3
4 4

Sample Output

102
1252

Anupam Bhattacharjee ( BUET PESSIMISTIC )

E means exponent, E means error. So try to avoid exponent whenever possible.



题意:计算图中的那个公式,给你的是n和a。

做法:直接用java大数来计算,非常方便。


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

public class Main {
	public static void main(String[] args) {
        Scanner scanf=new Scanner(System.in);
        BigInteger a,b,c;
        int i,n;
        while(scanf.hasNext())
       {
        	BigInteger t=new BigInteger("1");
        	BigInteger t1=new BigInteger("1");
        	BigInteger ans=new BigInteger("0");
        	n=scanf.nextInt();
        	a=scanf.nextBigInteger();
        	for(i=1;i<=n;i++)
        	{
        		t=t.multiply(a);
        		t1=t.multiply(BigInteger.valueOf(i));
        		ans=ans.add(t1);
        	}
        	System.out.println(ans);
       }
    }

}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值