递推
1 #include <iostream> 2 using namespace std; 3 double f[10000]; 4 double c; 5 int main() 6 { 7 f[0]=0; 8 for(int i=1;i<=10000;i++) f[i]=1.0/(i+1)+f[i-1]; 9 while(cin>>c,c!=0) 10 { 11 int m=1; 12 while(f[m]<c) m++; 13 cout<<m<<" card(s) "; 14 } 15 }