题目链接:http://poj.org/problem?id=1003
Source Code
Problem: 1003 | User: yuanting0505 | |
Memory: 256K | Time: 0MS | |
Language: C++ | Result: Accepted |
- Source Code
#include <iostream> #include <string> #include <map> using namespace std; int main(int argc, const char * argv[]) { map<int,int> result; map<int,int>::iterator iter; float num; int i=0; cin>>num; while(num!=0.00) { int count=1; float sum=1.0/2; while(sum<num) { count++; sum+=1.0/(count+1); } result[i]=count; i++; cin>>num; } for(iter=result.begin();iter!=result.end();iter++) { cout<<iter->second<<" card(s)"<<endl; } return 0; }