#P17463. Iridescence / PYTRIP4

    ID: 19975 远端评测题 2500ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>数学数论O2优化类欧几里得算法Stern-Brocot 树Dirichlet 卷积亚线性快速求和算法

Iridescence / PYTRIP4

Background

This problem is an enhanced version of SPOJ PYTRIP3.

Problem Description

Given a positive integer NN. Find the number of distinct right triangles whose hypotenuse length is at most NN, and whose three side lengths are all integers.

Input Format

One line containing one positive integer NN.

Output Format

One line containing one non-negative integer, representing the answer.

1000000000000
4179478903392

Hint

For all testdata, 1≤N≤31415926535897≈3.14×10131\le N\le 31415926535897\approx 3.14\times 10^{13}.

The time limit is about 1.51.5 times the running time of the standard solution on the slowest case.

Translated by ChatGPT 5