結果

問題 No.3054 ほぼ直角二等辺三角形
ユーザー 37zigen37zigen
提出日時 2019-12-19 06:33:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 78,852 KB
実行使用メモリ 57,004 KB
最終ジャッジ日時 2023-09-21 06:27:23
合計ジャッジ時間 6,867 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
56,916 KB
testcase_01 AC 166 ms
56,828 KB
testcase_02 AC 168 ms
56,864 KB
testcase_03 AC 169 ms
56,468 KB
testcase_04 AC 167 ms
56,988 KB
testcase_05 AC 169 ms
56,728 KB
testcase_06 AC 166 ms
56,560 KB
testcase_07 AC 166 ms
56,936 KB
testcase_08 AC 169 ms
56,544 KB
testcase_09 AC 169 ms
56,944 KB
testcase_10 AC 168 ms
56,732 KB
testcase_11 AC 168 ms
56,848 KB
testcase_12 AC 168 ms
56,696 KB
testcase_13 AC 165 ms
57,004 KB
testcase_14 AC 167 ms
56,580 KB
testcase_15 AC 169 ms
56,548 KB
testcase_16 AC 166 ms
56,536 KB
testcase_17 AC 169 ms
56,880 KB
権限があれば一括ダウンロードができます

ソースコード

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