結果
| 問題 |
No.1593 Perfect Distance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 22:28:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 685 bytes |
| コンパイル時間 | 296 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2024-07-01 17:08:13 |
| 合計ジャッジ時間 | 6,421 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 11 TLE * 1 -- * 5 |
ソースコード
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()