結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー 37zigen37zigen
提出日時 2019-12-19 06:32:40
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 3,291 ms
コンパイル使用メモリ 77,064 KB
実行使用メモリ 60,800 KB
最終ジャッジ日時 2023-09-21 06:27:16
合計ジャッジ時間 8,481 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;
import java.io.*;
import java.math.*;

class Main{

	public static void main(String[] args){
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int X=sc.nextInt();
		long u0=1,u=u0;
		long v0=1,v=v0;
		while(true){
			long nu=u*u0+2*v*v0;
			long nv=u*v0+v*u0;
			if(nu*nu-2*nv*nv!=1&&nu*nu-2*nv*nv!=-1){
				throw new AssertionError();
			}else if(nu*nu-2*nv*nv==-1){
				System.out.println(nu+" "+nv+" "+(nu*nu-2*nv*nv));
			}
			u=nu;
			v=nv;
			if(u*u-2*v*v==-1&&v>=Math.pow(10,X-1)){
				long a=(u-1)/2,c=v,b=a+1;
				System.out.println(a+" "+b+" "+c);
				//System.out.println(a+" "+b+" "+(a*a+b*b)+" "+(c*c));
				return;
			}
		}
	}
	
	void tr(Object...objects){
		System.err.println(Arrays.deepToString(objects));
	}
}
0