結果

問題 No.2358 xy+yz+zx=N
ユーザー 👑 timitimi
提出日時 2023-07-05 23:12:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 87,640 KB
最終ジャッジ日時 2023-09-26 23:56:18
合計ジャッジ時間 3,862 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,536 KB
testcase_01 AC 80 ms
71,788 KB
testcase_02 AC 74 ms
71,868 KB
testcase_03 AC 79 ms
71,788 KB
testcase_04 AC 76 ms
71,332 KB
testcase_05 AC 76 ms
71,484 KB
testcase_06 AC 80 ms
75,964 KB
testcase_07 AC 129 ms
77,416 KB
testcase_08 AC 250 ms
86,936 KB
testcase_09 AC 252 ms
87,640 KB
testcase_10 AC 229 ms
81,220 KB
testcase_11 AC 240 ms
82,532 KB
testcase_12 AC 195 ms
79,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
ans=[]
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
  
for x in range(N+1):
  if x>(N/3)**0.5:
    break
  A=make_divisors(N+x**2)
  for a in A:
    b=(N+x**2)//a
    y,z=a-x,b-x
    if x<=y and y<=z:
      ans.append((x,y,z))
      ans.append((x,z,y))
      ans.append((y,x,z))
      ans.append((y,z,x))
      ans.append((z,x,y))
      ans.append((z,y,x))
ans=set(ans)
print(len(ans))
for i in ans:
  print(*i)
0