#include<stdio.h>
int main(){
float a,sum,i,p;
while(1){
sum=0;
scanf("%f",&a);
if(a==0.00)
break;
for(i=2;i<277;i++){
sum=sum+(1/i);
if(sum>a){
printf("%.0f card(s)\n",i-1);
break;
}
}
}
return 0;
}
int main(){
float a,sum,i,p;
while(1){
sum=0;
scanf("%f",&a);
if(a==0.00)
break;
for(i=2;i<277;i++){
sum=sum+(1/i);
if(sum>a){
printf("%.0f card(s)\n",i-1);
break;
}
}
}
return 0;
}
Hi, I've used sum>a as loop termination condition, you have used condition i<277 in, what 277 means here ?
ReplyDeletethanks in advance
actually u can see from test cases that for 0 max 273 cards can be used. so i just checked for all cards one by one :)
Delete