2018蓝桥杯第三题--复数幂

1.问题

设i为虚数单位。对于任意正整数n,(2+3i)^n 的实部和虚部都是整数。
求 (2+3i)^123456 等于多少? 即(2+3i)的123456次幂,这个数字很大,要求精确表示。
答案写成 "实部±虚部i" 的形式,实部和虚部都是整数(不能用科学计数法表示),中间任何地方都不加空格,实部为正时前面不加正号。(2+3i)^2 写成: -5+12i,
(2+3i)^5 的写成: 122-597i

注意:需要提交的是一个很庞大的复数,不要填写任何多余内容。
 

2.代码

package exercise;

import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		 BigInteger a=new BigInteger("2");
		 BigInteger b=new BigInteger("3");
		 BigInteger c=new BigInteger("2");
		 BigInteger d=new BigInteger("3");
		 BigInteger b1=new BigInteger("0");
		 BigInteger b2=new BigInteger("0");
	for(int count=1;count<=1234;count++){
		b1=(a.multiply(c)).subtract(b.multiply(d));
		b2=(b.multiply(c)).add(a.multiply(d));
		c=b1;
		d=b2;
	}
			 System.out.println(b1+"+"+b2+"i"); 
		 
}}

3.结果

3315289662766148870743167908385451073665293587658411401043604618221612348573778600403096707234086336629458982284317265856776962856263159768406500640689004185502189473076055878936122165313093540467100343421812468441164766803900759730905238966606877577223935050362627612119067155219951055997177983863076074922705393961900526580534138562152205999572715843524896927917822636821676460252079569756941166699941484191372653457402275060830988659844565596423579014048445961733501353083899091464336627824035320324187389259256021224100720392801577972104899203603100391934140312083456713527941159346295362712482097150877587712241300610379425912357570235521590474579356765092115526151050635580445943154

猜你喜欢

转载自blog.csdn.net/weixin_42565135/article/details/88584433