10119_ArithmeticProgressions

2022-5-16 18:16| 发布者: Hocassian| 查看: 79| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504570851999-Problem List-采集的数据-后羿采集器.html

Pro.ID

10119

Title

Arithmetic Progressions

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10119

AC

62

Submit

229

Ratio

27.07%

时间&空间限制

  • Time Limit: 10000/4000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+n×b where n = 0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.

    Write a program that finds all arithmetic progressions of length n in the set S of bisquares. The set of bisquares is defined as the set of all integers of the form p2 + q2 (where p and q are non-negative integers).

    输入

    Multi test cases. Each case has two lines :

    Line 1:  N (3 ≤ N ≤ 25), the length of progressions for which to search

    Line 2:  M (1 ≤ M ≤ 250), an upper bound to limit the search to the bisquares with 0 ≤ p, qM.

    输出

    Description

    An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+n×b where n = 0, 1, 2, 3, ... . For this problem, a is a non-negative integer and b is a positive integer.

    Write a program that finds all arithmetic progressions of length n in the set S of bisquares. The set of bisquares is defined as the set of all integers of the form p2 + q2 (where p and q are non-negative integers).

    Input

    Multi test cases. Each case has two lines :

    Line 1:  N (3 ≤ N ≤ 25), the length of progressions for which to search

    Line 2:  M (1 ≤ M ≤ 250), an upper bound to limit the search to the bisquares with 0 ≤ p, qM.

    Output

    For each case :

    If no sequence is found, a singe line reading 'NONE'. Otherwise, output one or more lines, each with two integers: the first element in a found sequence and the difference between consecutive elements in the same sequence. The lines should be ordered with smallest-difference sequences first and smallest starting number within those sequences first.

    There will be no more than 10,000 sequences.

    After each case , output a blank line.

    Sample Input

    5
    7

    3
    2

    Sample Output

    1 4
    37 4
    2 8
    29 8
    1 12
    5 12
    13 12
    17 12
    5 20
    2 24

    0 1
    0 2
    2 3
    0 4

    Source

    样例输入

    5
    7

    3
    2

    样例输出

    1 4
    37 4
    2 8
    29 8
    1 12
    5 12
    13 12
    17 12
    5 20
    2 24

    0 1
    0 2
    2 3
    0 4

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部