Title Address: POJ 1905
Double-enumerate H, and then determine if the arc length meets the criteria. Focus on the accuracy of the problem, the specific look at the code bar.
#include <iostream> #include <string.h> #include <math.h> #include <queue> #include < algorithm> #include <stdlib.h> #include <map> #include <set> #include <stdio.h>using namespace std; #define LL __int64#define Pi ACOs ( -1.0) const int Mod=9901;const int Inf=0x3f3f3f3f;const double Eqs=1e-6;bo Ol Judge (double F1, double F2) {return f2-f1>1e-4;} BOOL Judge (double F1, double F2) {return fabs (F1-F2) <eqs;} Double Bin_search (double lenth, double L) {Double low=0, HIGH=L/2, Mid, R; while (Judge (Low,high)) {mid= (Low+high)/2; R= (4*mid*mid+l*l)/(8*MID); if (2*r*asin (L/(2*r)) < lenth) Low=mid; else High=mid; } return mid;} int main () {double L, C, N, Lenth; while (scanf ("%lf%lf%lf", &l,&c,&n)!=eof&&l>=0) {lenth= (1+n*c) *l; printf ("%.3f\n", Bin_search (Lenth, L)); } return 0;}
POJ 1905 Expanding Rods (two points + computational geometry + precision Processing)