Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- void calculateDiff(unsigned longint);
- void calculateDiff(unsigned long int N){
- unsigned long int s1,s2,s3,diff;
- s1= (N*(N+1)*(2*N +1))/6;
- s2 = (N*(N+1))/2;
- s3 = s2*s2;
- diff = s3-s1;
- cout<<diff<<endl;
- }
- int main() {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT */
- int T;
- unsigned long int N;
- //Get test case
- cin>>T;
- //Get Natural Number
- for(int i=1;i<=T;i++){
- cin>>N;
- calculateDiff(N);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement