Problem:
Score : 100 points

Problem Statement

Given an integer a as input, print the value a + a^2 + a^3.

Constraints

1 \leq a \leq 10

a is an integer.

Input

Input is given from Standard Input in the following format:

a

Output

Print the value a + a^2 + a^3 as an integer.

Sample Input 1

2

Sample Output 1

14

When a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.

Print the answer as an input. Outputs such as 14.0 will be judged as incorrect.

Sample Input 2

10

Sample Output 2

1110

Solution in C++ (GCC 9.2.1) (judge verdict: Time Limit Exceeded)

#pragma GCC optimize("O1") 
#pragma GCC optimize("O2") 
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
using namespace std; 
#define test int tt;cin>>tt;while(tt--)

int main() 
{ 
  	int64_t n,m,k; cin>>n>>m>>k; 
	vector<int64_t> arr1; for(int64_t i=0;i<n;i++) {int64_t x; cin>>x; arr1.push_back(x);}
	vector<int64_t> arr2; for(int64_t i=0;i<m;i++) {int64_t x; cin>>x; arr2.push_back(x);}
	// declaring resultant container 
	vector<int64_t> arr3(n+m); 

	// sorting initial containers 
	sort(arr1.begin(), arr1.end()); 
	sort(arr2.begin(), arr2.end()); 
	merge(arr1.begin(), arr1.end(), arr2.begin(), arr2.end(), arr3.begin()); 
    int64_t N=n+m;
    for (size_t i = 0; i < arr3.size()-1; i++)
    {
        arr3[i+1] += arr3[i];
        //cout<<arr3[i]<<" ";
    }
    //cout<<arr3[n+m-1]<<endl;
    int64_t i{N/2},z{0};
    if(k > arr3[0] && k < arr3[n+m-1])
    {
        while(true)
        {
            if(k> arr3[i] and k < arr3[i+1]){break;}
            else if(k == arr3[i]) {break;}
            else if(k < arr3[i] and i>=1){ i /= 2;}
            else if(k > arr3[i+1] and i<N) {i *=2;}
            else {break;}
        }
        z = i + 1;
    }
    if(k < arr3[0]) cout<<0<<endl;
    else if(k==arr3[0]) cout<<1<<endl;
    else if(k>=arr3[N-1] and i>0) cout<<N<<endl;
    else cout<<z<<endl;
    // int64_t count{0},i{0},sum{0},flag=INT_MAX;
    // sum = accumulate(arr3.begin(),arr3.end(),sum);
    // if(k<sum){
    //     flag=-1;
    //     while (k>arr3[i])
    //     {
    //         k -= arr3[i];
    //         ++count; ++i;
    //     } 
    // }

    // flag == -1 ? cout<<count<<endl : cout<<n+m<<endl;

	return 0; 
}