結果
| 問題 | No.1593 Perfect Distance |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 22:28:57 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 685 bytes |
| 記録 | |
| コンパイル時間 | 1,267 ms |
| コンパイル使用メモリ | 20,568 KB |
| 実行使用メモリ | 30,456 KB |
| 最終ジャッジ日時 | 2026-03-22 19:07:44 |
| 合計ジャッジ時間 | 22,273 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 6 |
ソースコード
from collections import defaultdict
from sys import stdin
def is_sqrt(n):
idx = defaultdict(int)
while n >= 4:
if n % 2:
break
else:
n //= 2
idx[2] += 1
i = 3
while n >= i * i:
if n % i:
i += 2
else:
n //= i
idx[i] += 1
idx[n] += 1
x = 1
for i in idx.values():
x *= i + 1
ret = True if x % 2 else False
return ret
def main():
input = lambda: stdin.readline()[:-1]
N = int(input())
ans = 0
n = N * N
for x in range(1, N):
y = n - x * x
if is_sqrt(y):
ans += 1
print(ans)
main()