Monday, 2 March 2015

Uva-12149 - Feynman Solution

/*Uva-12149 - Feynman Solution */

Solution:

#include<bits/stdc++.h>
using namespace std;
int ar[110];
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){

    ar[1] = 1;
    for(int i = 2; i < 101; i++)ar[i] = (i*i)+ar[i-1];
    int n;
    while(cin >> n && n){
        cout << ar[n] << endl;
    }
    return 0;
}

No comments:

Post a Comment