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 |
Re:怎么会Time Limit Exceeded!高人指教啊。小弟菜,想了许久依然茫然……In Reply To:怎么会Time Limit Exceeded!高人指教啊。小弟菜,想了许久依然茫然…… Posted by:crg511 at 2008-04-28 10:05:57 #include<iostream> using namespace std; int main() { double a[1000]; double num,total; int k=-1,i; cin>>num; while (num!=0.00) { double n=1; total=1/(n+1); while (total<num) { n=n+1; total=total+1/(n+1); } if (total>=num) { k=k+1; a[k]=n; } cin>>num; } for(i=0;i<=k;i++) cout<<a[i]<<" 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