Algorithm is correct according to me.. tried both with float and double.. I am using the relation: e(i)= 0.45*i + e(i-1)/10 Please help..
#include<iostream>
#include<cstdio>
using namespace std;
float e[100005];
main(){
int tst,lim=1;
scanf("%d",&tst);
while(tst--){
int n,i;
scanf("%d",&n);
if(e[n]) printf("%.7f\n", e[n]);
else{
for(i=lim;i<=n;i++) e[i]=0.45*(float)i + e[i-1]/10;
lim=n;
}
printf("%.7f\n", e[n]);
}
}