I was solving for SPOJ : MAXLN here is some code
CASE 1
#include <cstdio>
int main()
{
int T,r; // r is integer here
float ans;
scanf("%d",&T);
for(int i=1;i<=T;i++){
scanf("%d",&r);
ans = 4*r*r + 0.25;
printf("Case %d: %.2f\n",i,ans);
}
return 0;
}
Input :- 2 1 1000000
Output :- 4.25 1385447424.00
CASE 2
#include <cstdio>
int main()
{
int T;
float ans,r;
scanf("%d",&T);
for(int i=1;i<=T;i++){
scanf("%f",&r);
ans = 4*r*r + 0.25;
printf("Case %d: %.2f\n",i,ans);
}
return 0;
}
Input :- 2 1 1000000
Output :- 4.25 3999999983616.00
CASE 2 got AC
Question :-
1 : why there is different answer for input 1000000.
2 : for input = 1000000 ans = (4 * 1000000 * 1000000) + 0.25 = 4000000000000.25 , then why CASE 2 got AC