Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么是 Time Limit Exceeded#include<iostream> #include<vector> using namespace std; int main() { vector<float> dvec; float test_case,sum=0.00; cin>>test_case; while(test_case!=0.00) {dvec.push_back(test_case); cin>>test_case; } int card_number; vector<float>::iterator iter; for(iter=dvec.begin();iter!=dvec.end();++iter) { card_number=1; while(1) { sum=sum+(float)1/(card_number+1); bool sings=(int)*iter==(int)sum; if(sings)break; ++card_number; } cout<<card_number<<" card(s)"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator