結果

問題 No.1593 Perfect Distance
ユーザー Kenneth YongKenneth Yong
提出日時 2021-07-09 22:42:05
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 13,322 ms
コンパイル使用メモリ 408,844 KB
実行使用メモリ 52,344 KB
最終ジャッジ日時 2023-09-14 10:00:54
合計ジャッジ時間 20,399 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 279 ms
50,284 KB
testcase_01 AC 278 ms
50,756 KB
testcase_02 AC 278 ms
50,252 KB
testcase_03 AC 278 ms
50,376 KB
testcase_04 AC 274 ms
52,344 KB
testcase_05 AC 280 ms
50,256 KB
testcase_06 AC 275 ms
50,276 KB
testcase_07 AC 275 ms
50,332 KB
testcase_08 AC 272 ms
50,300 KB
testcase_09 AC 278 ms
50,316 KB
testcase_10 AC 275 ms
50,360 KB
testcase_11 AC 282 ms
50,376 KB
testcase_12 AC 281 ms
50,820 KB
testcase_13 AC 280 ms
50,416 KB
testcase_14 AC 284 ms
50,288 KB
testcase_15 AC 286 ms
50,788 KB
testcase_16 AC 285 ms
50,348 KB
testcase_17 AC 275 ms
50,304 KB
testcase_18 AC 276 ms
50,264 KB
testcase_19 AC 273 ms
50,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.math.sqrt
import kotlin.math.round

fun main() {
	val n = readLine()!!.toLong();
	
	// a^2 + b^2 = n^2 -> 1 <= a < n
	var ans = 0;
	for (a in 1L..(n - 1)) {
		val current = n * n - a * a;
		val root = round(sqrt(current.toDouble())).toLong();
		if (current == (root * root)) ans++;
	}
	
	println(ans);
}
/*
C:\Users\kenne\OneDrive\Desktop\competitive_programming\kotlinmain.kt
*/
0