zewenli98 / web_tasks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

P1

pujiaxun opened this issue · comments

commented

数据精度并不够呀~

我一开始调试的时候long也会溢出,不知道在C++里面用什么,希望学长能够指点一下~~
下面是Java代码:

import java.math.BigInteger;

public class Fibonacci {

public static void main(String[] args) {
BigInteger a = BigInteger.ONE;
BigInteger b = BigInteger.ONE;
for (int i = 0; i < 50; i++) {
System.out.print(a + " " + b + " ");
a = a.add(b);
b = a.add(b);
}
}
}

我一开始调试的时候long也会溢出,不知道在C++里面用什么,希望学长能够指点一下~~
下面是Java代码:

import java.math.BigInteger;

public class Fibonacci {

public static void main(String[] args) {
	BigInteger a = BigInteger.ONE;
	BigInteger b = BigInteger.ONE;
	for (int i = 0; i < 50; i++) {
		System.out.print(a + " " + b + " ");
		a = a.add(b);
		b = a.add(b);
	}
}

}

commented