Java 的函数 调用

/*

* BigInteger a = BigInteger.valueOf(100);

* BigInteger b = BigInteger.valueOf(50);

* BigInteger c = a.add(b) // c = a + b;
主要有以下方法可以使用: BigInteger add(BigInteger other)
BigInteger subtract(BigInteger other)
BigInteger multiply(BigInteger other)
BigInteger divide(BigInteger other)
BigInteger mod(BigInteger other)
int compareTo(BigInteger other)
static BigInteger valueOf(long x)
BigInteger dp[] = new BigInteger[5010];


*/
import java.math.*;
import java.util.*;
import java.io.*;

public class Main {
    static public void main(String args[]) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        String st[] = new String[5010];
        int a[] = new int[5010];
        BigInteger dp[] = new BigInteger[5010];
        dp[0] = new BigInteger("0");

        for (int i=1; i<=N; i++) {
            st[i] = cin.next();
            a[i] = cin.nextInt();
            if (st[i].compareTo("win") == 0) {
                dp[i] = dp[i-1];
            } else {
                dp[i] = dp[i-1];
                for (int j=i-1; j>0; j--)
                    if (st[j].compareTo("win")==0 && a[j] == a[i]) {
                        BigInteger temp = new BigInteger("2");
                        temp = temp.pow(a[j]);
                        temp = temp.add(dp[j]);
                        if (temp.compareTo(dp[i]) == 1)
                            dp[i] = temp;
                        j = 1;
                    }
            }
        }

        System.out.println(dp[N]);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值