problem link:
Discuss: In this you just you have to simply calculate (((n*(n+2)/2)*3)-6)
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,i,j,sum,last,odd;
while(cin >>n)
{
odd=(((n*(n+2)/2)*3)-6);
cout <<odd<<endl;
}
return 0;
}
Discuss: In this you just you have to simply calculate (((n*(n+2)/2)*3)-6)
try yourself before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,i,j,sum,last,odd;
while(cin >>n)
{
odd=(((n*(n+2)/2)*3)-6);
cout <<odd<<endl;
}
return 0;
}
No comments:
Post a Comment