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 |
怎么会超时呢??#include <iostream> #include <iomanip> using namespace std; int main() { int n; cin>>n; cout<<"Cards Overhang"<<endl; while ( n && n<100000 && n != EOF ) { long double sum = 0; int count = 2; long double num = 0.5; int tn = n; while ( tn ) { sum += num; if ( count<=2 ) num = num/2; else num = 1.0/(count+2); tn--; count += 2; } cout<<setprecision(3); cout<<fixed<<showpoint; cout<<setw(5)<<n<<" "<<sum<<endl; cin>>n; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator