i've modified my algorithm
but i'm getting wrong answer. someone help..
#include<iostream>
using namespace std;
unsigned long long start,end,arr[1000001],arr2[1000001];
int main(){
int j,t,i,n;
for(i=0;i<1000000;i++){
arr[i]=i+1+arr[i-1];
}
for(i=0;i<1000000;i++)
{
arr[i]+=arr[i-1];
}
arr2[1]=1;
arr2[2]=3;
for(i=3;i<=1000000;i++){
arr2[i]=(i*(i+1)/
2)+arr2[i-2];
}
cin>>t;
while(t--){
cin>>n;
cout<<arr[n-1]+arr2[n-1]<<endl;}
return 0;
}
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.