結果
| 問題 | No.1593 Perfect Distance | 
| コンテスト | |
| ユーザー |  Kiri8128 | 
| 提出日時 | 2021-07-09 22:44:33 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 85 ms / 2,000 ms | 
| コード長 | 319 bytes | 
| コンパイル時間 | 325 ms | 
| コンパイル使用メモリ | 82,180 KB | 
| 実行使用メモリ | 75,776 KB | 
| 最終ジャッジ日時 | 2024-07-01 17:55:57 | 
| 合計ジャッジ時間 | 2,208 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
# C
def sqrt(n):
    if n == 0: return 0
    x = 1 << (n.bit_length() + 1) // 2
    y = (x + n // x) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x
n = int(input())
N = n ** 2
ans = 0
for x in range(1, n):
    a = sqrt(N - x * x)
    if x ** 2 + a ** 2 == N:
        ans += 1
print(ans)
            
            
            
        