全改用大数第三个还是错了啊
  • 板块P1150 Peter 的烟
  • 楼主QAQ5
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/1 14:13
  • 上次更新2025/1/1 19:17:07
查看原帖
全改用大数第三个还是错了啊
749028
QAQ5楼主2025/1/1 14:13
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Run();//多余的转移,只是因为main不是构造方法,而且是静态的。一般不用静态main这种方式,但我连这都不会调
    }
}

class Run {
    final BigInteger buttToOneNum;

    Run() {
        BigInteger total = new BigInteger("0");
        BigInteger current;
        {//封定输入范围
            Scanner scanner = new Scanner(System.in);
            current = new BigInteger(scanner.next());
            buttToOneNum = new BigInteger(scanner.next());
        }
        do {
            total = total.add(current);
            current = exchange(current);
        } while (!current.equals(new BigInteger("0")));
        System.out.println(total);
    }

    BigInteger exchange(BigInteger buttNum) {
        return buttNum.divide(buttToOneNum);
    }
}

2025/1/1 14:13
加载中...