아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Plus Minus Four Squares

시간 제한1초메모리 제한1024 MB

요약
주어진 규칙에 따라 n을 부호가 붙은 네 제곱수의 합으로 나타내는 서로 다른 방법의 수를 센다.
난이도

보통10점 중 5점

유형
완전 탐색, 수학, 조합론, 구현
정답자
아직 제출이 없습니다

문제

Every non-negative integer nn may be written as the sum of the squares of four integers:

n=a2+b2+c2+d2n = a^2 + b^2 + c^2 + d^2

By allowing subtraction, nn may be written in many more ways; in fact infinitely many.

In this problem you will count the number of different ways to express an input nn as a sum or difference of four squares with several restrictions:

First, we need to decide what different means.

Any of aa, bb, cc, dd may be replaced by its negative. We do not want to count these as different so we will only count different squared values.

Reordering aa, bb, cc, dd does not give a different representation.

So, we define a plus minus four square representation of a non-negative integer nn as a sequence of four perfect squares in non-increasing order with plus or minus signs whose computation results in nn.

In addition, we add the following restrictions:

  • The first square must be no more than nn to avoid having infinitely many representations.
  • If the same square appears multiple times all appearances must be preceded by (a possibly implicit) plus sign or all must be preceded by a minus sign. This avoids something like: 64+36−36+064 + 36 - 36 + 0
  • A square of zero must be preceded by a plus sign.

For example, the only sums of squares which add to 64 are:

64+0+0+064 + 0 + 0 + 0 16+16+16+1616 + 16 + 16 + 16

If we allow minus signs with the above additional restrictions we have the following which each sum up to 6464:

64+25−16−964 + 25 - 16 - 9 64−25+16+964 - 25 + 16 + 9 64+0+0+064 + 0 + 0 + 0 49+49−25−949 + 49 - 25 - 9 49+36−25+449 + 36 - 25 + 4 49+25−9−149 + 25 - 9 - 1 49+16−1+049 + 16 - 1 + 0 36+36−9+136 + 36 - 9 + 1 36+36−4−436 + 36 - 4 - 4 36+25+4−136 + 25 + 4 - 1 36+16+16−436 + 16 + 16 - 4 16+16+16+1616 + 16 + 16 + 16

Write a program which takes as input a non-negative integer nn and outputs a count of the number of different four square plus minus representations of nn.

입력

Input consists of one line containing a single non-negative decimal integer (0<n≤50000 < n ≤ 5000).

출력

There is one line of output that consists of a single decimal integer giving a count of the number of different four square plus minus representations of nn.

예제3

  1. 예제 1

    입력
    64
    
    예상 출력
    12
    
  2. 예제 2

    입력
    65
    
    예상 출력
    10
    
  3. 예제 3

    입력
    2023
    
    예상 출력
    245