%I #20 Aug 26 2019 08:23:17
%S 1,3,6,10,16,22,29,39,48,61,72,84,101,115,135,151,174,192,211,238,259,
%T 289,312,336,370,396,433,461,501,531,562,606,639,686,721,757,808,846,
%U 900,940,981,1039,1082,1143,1188,1252,1299,1347,1415,1465,1536,1588,1641
%N a(n) is the number of different sizes of integer-sided rectangles which can be placed inside an n X n square.
%C Rectangles can be placed in any orientation and in particular their sides are not required to be parallel to the sides of the square.
%C A000217(n) enumerates the subset with sides not larger than n. For n < 5, a(n) = A000217(n).
%C Condition for rectangles L X W which have length L > n: n - L/sqrt(2) > W/sqrt(2) where L/sqrt(2) and W/sqrt(2) are projections on the n X n square's sides.
%F a(n) = A000217(n) + A327142(n).
%e For n = 3 there are 6 distinct sizes of rectangle that can be placed into a 3 X 3 square:
%e ... ... ... ... ... ###
%e ... ... ... ##. ### ###
%e #.., ##., ###, ##., ###, ###
%e For n = 8 there are 36 distinct sizes of rectangle that can be placed with their sides parallel to the sides of the square; in addition, 9 X 1, 9 X 2 and 10 X 1 rectangles can also be placed. Hence a(8) = 39.
%o (C++)
%o #include <iostream>
%o #include <cmath>
%o #include <vector>
%o using namespace std;
%o int main() {
%o int n;
%o cin>>n;
%o vector <int> v;
%o for (int i=1; i<=n; i++)
%o {int count=0;
%o for (int j=1; j<=i; j++)
%o for (int k=j; k<=i; k++)
%o {count++;}
%o //Diagonally placed ii-length, jj-width of diagonal rectangle
%o for (int ii=i+1; ii<=int(sqrt(2)*i); ii++)
%o for (int jj=1; jj<=i; jj++)
%o if ((double(i)-double(ii)/sqrt(2))-double(jj)/sqrt(2)>0)
%o { count++;}
%o v.push_back(count);
%o }
%o for (int i=0; i<v.size(); i++) cout << v[i] << ", ";
%o return 0;
%o }
%Y Cf. A000217, A327142.
%K nonn
%O 1,2
%A _Kirill Ustyantsev_, Aug 23 2019
|