标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 269 Accepted Submission(s): 63
这条是2013年长沙的题目
二分的题目就是卡姿势,同浮点误差~
二分姿势稍有不当就WA
求第 i 层的圆的半径一层层的加又WA , 要直接用公式 ri = add * i + r ;
#include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <cmath> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; inline double getlen(int n,double r) { return 2.0 * r * tan( PI / n ); } int main() { ios::sync_with_stdio(0); #ifdef LOCAL freopen("in.txt","r",stdin); #endif // LOCAL double R,r,H,F,S; while( cin >> R >> r >> H >> F >> S ){ double h = H / F , ans = 0 , add = ( R - r ) / F , ri ; for( int i = 0 ; i < F ; i++ ) { ri = add * i + r ; int ll = 3 ,rr = 100000 ; double area ; int num; while( ll <= rr ) { int mm = ( ll + rr ) >> 1; double tmp = getlen( mm , ri ) * h; if( S + eps < tmp ){ area = tmp , num = mm; ll = mm + 1; } else{ rr = mm - 1; }
} ans += num * area; } printf("%.3lf\n",ans); } return 0; }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/YRETSIM/p/4001142.html