結果

問題 No.152 貯金箱の消失
ユーザー takakintakakin
提出日時 2020-07-12 20:37:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,126 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 30,252 KB
最終ジャッジ日時 2024-04-23 20:08:59
合計ジャッジ時間 8,111 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 48 ms
11,008 KB
testcase_05 AC 52 ms
10,880 KB
testcase_06 AC 73 ms
11,136 KB
testcase_07 AC 346 ms
14,208 KB
testcase_08 AC 2,126 ms
30,252 KB
testcase_09 AC 2,124 ms
30,244 KB
testcase_10 AC 1,689 ms
21,160 KB
testcase_11 AC 916 ms
16,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
nn=int(n**0.5)+1
A=set()
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
for i in range(1,nn):
	for j in range(i+1,nn):
		if 8*j*(i+j)<=n:
			a,b=j**2-i**2,2*i*j
			if a>b:
				a,b=b,a
			a,b=a//gcd(a,b),b//gcd(a,b)
			A.add(a*10**8+b)
print(len(A))
0