纯规律题:找到n=3时,分割数为20,从而可发现2,8, 20之间差的关系正好是6的倍数。
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include
"
iostream
"
using namespace std;
int a[ 10000 ];
int main()
{
int t;
int n;
cin >> t;
while (t -- )
{
cin >> n;
a[ 1 ] = 2 ;
for ( int i = 2 ;i <= n;i ++ )
a[i] = a[i - 1 ] + 6 * (i - 1 );
cout << a[n] << endl;
}
return 0 ;
}
using namespace std;
int a[ 10000 ];
int main()
{
int t;
int n;
cin >> t;
while (t -- )
{
cin >> n;
a[ 1 ] = 2 ;
for ( int i = 2 ;i <= n;i ++ )
a[i] = a[i - 1 ] + 6 * (i - 1 );
cout << a[n] << endl;
}
return 0 ;
}