Invariant Polynomials | 프로그래밍의 벗 PivotOJ
PivotOJ

Invariant Polynomials

시간 제한: 1000ms메모리 제한: 512MB출처: NEERC Northern Subregional 2003BOJ 7478

문제

Consider a real polynomial P(x, y) in two variables. It is called invariant with respect to the rotation by an angle α if P(x cos α − y sin α, x sin α + y cos α) = P(x, y) for all real x and y. Let’s consider the real vector space formed by all polynomials in two variables of degree not greater than d invariant with respect to the rotation by 2π/n. Your task is to calculate the dimension of this vector space.

You might find useful the following remark: Any polynomial of degree not greater than d can be uniquely written in form P(x,y)=i,j0i+jdaijxiyjP(x, y)=\displaystyle\sum_{i,j\ge 0\atop i+j\le d} a_{ij} x^iy^j for some real coefficients aij.

입력

The input file contains two positive integers d and n separated by one space. It is guaranteed that they are less than one thousand.

출력

Output a single integer M which is the dimension of the vector space described.

예제

예제 1

입력
1 1
출력
3
코드를 제출하려면 로그인하세요.