题解 SP10509 【CRDS - Cards】

· · 题解

SP10509 CRDS - Cards

OEIS大发好!

我们手算出前几个数据:

x y
1 2
2 7
3 15
4 26
5 40
6 57
7 77
8 100

然后把他输入OEIS就会蹦出来个A005449,里边给的通项是 a_i=\dfrac{i\times (3\times i+1)}{2} ,然后直接输出即可。

//n*(3*n + 1)/2
#include<bits/stdc++.h>
using namespace std;
int T;
int main()
{
    cin>>T;
    while(T--)
    {
        long long n;
        cin>>n;
        cout<<(n*(3*n+1)/2)%1000007<<endl;
    }
    return 0;
}