結果
問題 | No.2358 xy+yz+zx=N |
ユーザー | Navier_Boltzmann |
提出日時 | 2023-06-23 22:34:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 353 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 95,616 KB |
最終ジャッジ日時 | 2024-07-01 17:39:42 |
合計ジャッジ時間 | 3,149 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
from collections import * from functools import * from itertools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) def f(M): tmp = [] n = 1 while n**2 < M: if M%n==0: tmp.append(n) tmp.append(M//n) n += 1 if n**2==M: tmp.append(n) return tmp def g(M,S): X = [] for s in f(M+S**2): if s-S<0: continue t = (M+S**2)//s if t-S<0: continue X.append((s-S,t-S)) return X ans = [] M = math.ceil(math.sqrt(N)+1) for i in range(M+1): if i**2>N: break for x,y in g(N,i): tmp = [i,x,y] for p in permutations(tmp): ans.append(tuple(p)) ans = set(ans) print(len(ans)) for a in ans: print(*a)