了解BigInteger类的使用——蓝桥杯公式求值问题(只对了一小部分)

本文介绍了在处理大数据范围时,如何使用Java的BigInteger类避免堆栈溢出问题。通过示例代码展示了一个公式求值问题的解决方案,尽管只解决了部分情况,作者提到可能需要动态规划(dp)来完全解决问题。
摘要由CSDN通过智能技术生成

当数据范围像上述题目中这么大时,不能用递归一层一层的去做,很容易堆栈溢出(个人教训及感觉)

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
    static String n,m;
    static int k;
    static BigInteger count=new BigInteger("0");
    public  static void main(String[] args) {
         Scanner sc=new Scanner(System.in);
         n=sc.nextLine();
         m=sc.nextLine();
         k=sc.nextInt();
         BigInteger div=new BigInteger("999101");
         BigInteger bn=new BigInteger(n);
         BigInteger bm=new BigInteger(m);
         BigInteger add=new BigInteger("0");
    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值