f(n)=(n*n+n)/2
g(n)=(n*n*n+3*n*n+2*n)/6
記得變數開大一點(long long int)
#include<iostream>
using namespace std;
int main()
{
long long int n, f, g;
while(cin>>n)
f = (n*n+n)/2;
g = (n*n*n+3*n*n+2*n)/6;
cout << f << " " << g << endl;
}