纯规律题:找到n=3时,分割数为20,从而可发现2,8, 20之间差的关系正好是6的倍数。
View Code
#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 ;}