#include<iostream> using namespace std; int main(){ double a[10011]; a[0]=0.0; for(int i = 1; i<10011;i++){ a[i] = (double) 1/(i+1) + a[i-1]; } double s; while(cin>>s){ if(s==0.00){ break; } for(int i= 1; i<10011; i++){ if(s<a[i]){ cout<<i<<" card(s)"<<endl; break; } } } return 0; } |
Double click to view unformatted code.