Thursday, November 16, 2017

1070 - A Simple Calculation COJ Problem Solution

http://coj.uci.cu/24h/problem.xhtml?pid=1070

In C++..................

#include<iostream>
#include <cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

////Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

int main()

{
    cin.tie(0);

    ios::sync_with_stdio(0);

    int N;

    while(cin>>N)
    {
       cout<<(N*(N+1)*(2*N+1))/6<<" "<<(N*N*(N+1)*(N+1))/4<<endl;
    }
    return 0;
}

No comments:

Post a Comment