SP14138 AFS - Amazing Factor Sequence

    • 3通过
    • 3提交
  • 题目来源 SPOJ 14138
  • 评测方式 RemoteJudge
  • 标签
  • 难度 尚无评定
  • 时空限制 457ms / 1536MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    Description

    设数列$\{a_n\}$满足$a_0=a_1=1$,$a_n=a_{n-1}+f(n)$。试求$a_n$的值。

    其中$f(n)$表示$n$的所有约数之和(不包括自身)。

    如$f(6)=1+2+3=6, f(7)=1$

    其中包含$T$组询问。

    Input

    输入的第一行包含一个整数$T$。

    接下来$T$行,每行一个$n$,代表一组询问

    Output

    输出 $T$行,每行一组询问的解。

    Notes

    $T\leqslant 10, 1<N\leqslant 10^6$

    题目描述

    Bhelu is the classmate of Bablu who made the Amazing Prime Sequence.

    He felt jealous of his classmate and decides to make his own sequence. Since he was not very imaginative, he came up with almost the same definition just making a difference in f(n):

    • a[0] = a[1] = 0.
    • For n > 1, a[n] = a[n - 1] + f(n), where f(n) is the sum of positive integers in the following set S.
    • S = {x | x < n and n % x = 0}.

      Now, Bablu asked him to make a code to find f(n) as he already had the code of his sequence. So, Bhelu asks for your help since he doesn't know Programming. Your task is very simple, just find a[n] for a given value of n (< 10^6).

    输入输出格式

    输入格式:

    Your code will be checked for multiple Test Cases.

    First Line of Input contains T (<= 100), the number of Test Cases.

    Next T lines contain a single positive integer N. (1 < N < 10^6).

    输出格式:

    Single line containing a[n] i.e. n-th number of the sequence for each test case.

    输入输出样例

    输入样例#1: 复制
    3
    3
    4
    5
    输出样例#1: 复制
    2
    5
    6
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。