# 1335
n = gets.chomp!.to_i
print "#{n*n+n} #{n*n+2*n} #{n*n}"
原文鏈接: http://acm.timus.ru/problem.aspx?space=1&num=1335
背景 輸出一組triplet (A,B,C) 滿足A B的平方和是以的倍數.
A B C 限制, 給定輸出的整數N, A B C均在區間[N**2, (N+1)**2] 中.
Input
contains one integer N (2 ≤ N ≤ 30000).
Output
Output three different integers A, B and C, that (A2 + B2)
is a multiple of C and N2 ≤ A, B, C ≤ (N+1)2. If two or more such triplets exist, output any
one. If there are no such triplets, then output "No solution".
Samples
input | output |
---|---|
2 |
8 6 4 |
1000 |
1000000 1000756 1000976 |
Problem Author: Den Raskovalov
Problem Source: The 10th Collegiate Programming Contest of the High School Pupils of the Sverdlovsk Region (October 16, 2004)
Problem Source: The 10th Collegiate Programming Contest of the High School Pupils of the Sverdlovsk Region (October 16, 2004)
Tags: none
其實這個題沒有想象是那麼複雜. --> 首先看這個公式
(n+1)^2 = n^2 + 2*n + 1 = (n+2)n + 1
所以在給定區間中 n*n, n*(n+1) , n*(n+2) 是均存在的. 如果取後面兩個大數的平方和, 他們一定是n^2倍數.