22621_Sumofpowers

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

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

Pro.ID

22621

Title

Sum of powers

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 20000/10000 K (Java/Others)
  • 描述

    A young schoolboy would like to calculate the sum

    for some fixed natural k and different natural n. He observed that calculating ik for all i ( 1 <= i <= n ) and summing up results is a too slow way to do it, because the number of required arithmetical operations increases as n increases. Fortunately, there is another method which takes only a constant number of operations regardless of n. It is possible to show that the sum Sk(n) is equal to some polynomial of degree k+1 in the variable n with rational coefficients, i.e.,

    for some integer numbers M, ak+1, ak, ... , a1, a0.

    We require that integer M be positive and as small as possible. Under this condition the entire set of such numbers (i.e. M, ak+1, ak, ... , a1, a0) will be unique for the given k. You have to write a program to find such set of coefficients to help the schoolboy make his calculations quicker.

    输入

    The input file contains a single integer k ( 1 <= k <= 20 ).

    输出

    Description

    A young schoolboy would like to calculate the sum

    for some fixed natural k and different natural n. He observed that calculating ik for all i ( 1 <= i <= n ) and summing up results is a too slow way to do it, because the number of required arithmetical operations increases as n increases. Fortunately, there is another method which takes only a constant number of operations regardless of n. It is possible to show that the sum Sk(n) is equal to some polynomial of degree k+1 in the variable n with rational coefficients, i.e.,

    for some integer numbers M, ak+1, ak, ... , a1, a0.

    We require that integer M be positive and as small as possible. Under this condition the entire set of such numbers (i.e. M, ak+1, ak, ... , a1, a0) will be unique for the given k. You have to write a program to find such set of coefficients to help the schoolboy make his calculations quicker.

    Input
    The input file contains a single integer k ( 1 <= k <= 20 ).
    Output
    Write integer numbers M, ak+1, ak, ... , a1, a0 to the output file in the given order. Numbers should be separated by one or more spaces. Remember that you should write the answer with the smallest positive M possible.
    Sample Input
    2
    Sample Output
    6 2 3 1 0
    Source

    样例输入

    2

    样例输出

    6 2 3 1 0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部