結果

問題 No.2358 xy+yz+zx=N
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-23 22:34:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 1,269 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 98,532 KB
最終ジャッジ日時 2023-09-14 10:13:30
合計ジャッジ時間 4,291 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
72,972 KB
testcase_01 AC 106 ms
73,104 KB
testcase_02 AC 110 ms
72,836 KB
testcase_03 AC 105 ms
72,952 KB
testcase_04 AC 105 ms
72,904 KB
testcase_05 AC 104 ms
73,144 KB
testcase_06 AC 113 ms
77,428 KB
testcase_07 AC 148 ms
81,000 KB
testcase_08 AC 414 ms
97,136 KB
testcase_09 AC 421 ms
98,532 KB
testcase_10 AC 352 ms
87,088 KB
testcase_11 AC 367 ms
88,940 KB
testcase_12 AC 303 ms
84,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)

    
0