PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000061. Bộ ba Pythagoras (Fermat vs. Pythagoras)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bộ ba Pythagoras (Fermat vs. Pythagoras)

Fermat vs. Pythagoras

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given N, consider all positive integer triples x<y<z<=N satisfying x^2+y^2=z^2. A triple is primitive if gcd(x,y,z)=1. Compute the number of primitive triples and the number of positive integers at most N that belong to no Pythagorean triple whose three values are at most N (including nonprimitive triples).

Input

An integer N.

Output

Two integers: the primitive-triple count and the number of unused positive integers.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le 100.
  • Subtask 2 (30 points): 1≤N≤100001\le N\le 10000.
  • Subtask 3 (50 points): 1≤N≤1061\le N\le 10^6.

Examples

Input

10

Output

1 4

Explanation

The only primitive triple with hypotenuse at most 10 is (3,4,5). Its multiple (6,8,10) also exists, leaving 1,2,7,9 unused.