結果
問題 | No.1593 Perfect Distance |
ユーザー | Kenneth Yong |
提出日時 | 2021-07-09 22:42:05 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 301 ms / 2,000 ms |
コード長 | 413 bytes |
コンパイル時間 | 11,295 ms |
コンパイル使用メモリ | 430,928 KB |
実行使用メモリ | 49,848 KB |
最終ジャッジ日時 | 2024-07-01 17:24:55 |
合計ジャッジ時間 | 18,450 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
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 */