NC25067. [USACO 2007 Mar L]Professor Snarf
描述
输入描述
Line 1: A single integer: A
输出描述
Line 1: A single line with two space-separated integers: Snarf's address and N
示例1
输入:
3
输出:
6 8
Python3 解法, 执行用时: 2001ms, 内存消耗: 0K, 提交时间: 2023-08-15 20:23:11
''' n * n + 2 * n + 1 - 2*x = (x * x - * x) * 2 n*(n+1) = 2 * x * x x * x - x = 2*(n+x+1)*(n-x-1) 2*n*n = 3*x*x+3*x+2 x > A ''' x = int(input()) + 1 while True: m = x*x*3 + x*3 + 2 n = (m//2)**0.5 if m % 2 == 0 and n == int(n) and n*(n+1) == 2*x*x: print(x, int(n)) break else: x += 1