#33234: 最快解


jasperlin0108@gmail.com (Jasper Lin)


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    while(cin>>n){
        cout<<n*(n+1)/2<<" "<<n*(n+1)*(n+2)/6<<"\n";
    }
    return 0;
}

 

參照高一數學:遞迴數列與Σ求和公式