ECMAR20C - Editorial

PROBLEM LINK:

Practice
Contest Link
Author: Shloka Mahesheka
Tester: Sandeep Singh
Editorialist: Shloka Mahesheka

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic maths

PROBLEM:

Given Sum of first n natural numbers. We need to find the Sum of the Cubes of First n Natural Numbers.

EXPLANATION:

Sum of Cubes of First n Natural Numbers is Sqaure of Sum of first N natural numbers.

SOLUTIONS:

Setter's Solution
#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    int S;

    while(t--){

        cin>>S;
        cout<<(S*S)<<endl;

    }

}
Tester's Solution
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////

void solve(){
		ll n,i,j,c,s;
	cin>>s;
		cout<<s*s<<endl;
	}

int main(){
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		#endif
		int t;
		cin>>t;
		while(t--)
    	solve();
} 
2 Likes