妹子求助

P1222 三角形

```cpp //Öª·ñ£¬Öª·ñ£¬Ó¦ÊÇÂ̷ʺìÊÝ£¡ #include <stdio.h> #include <algorithm> using std::sort; const double eps = 1e-2; const int maxn = 2000 + 15; const double mmax = 1145141919.0; const double mmin = -1145141919.0; int L = mmax , R = mmin; struct Triangle { int x; int y; int m; inline double l( double height ) { if( height > y && height < ( y + m ) ) return ( double )x; else return 0.0; } inline double r( double height ) { if( height > y && height < ( y + m ) ) return ( double )( x + m - ( height - ( double )y ) ); else return 0.0; } }; struct Line { double l; double r; }; Triangle a[ maxn ]; Line line[ maxn ]; int n; inline double abs( double a ) //¾ø¶ÔÖµ { if( a > 0 ) return a; else return -a; } inline bool cmp( double a , double b , double _eps ) //¸¡µãÊýÅÐµÈ { if( abs( a - b ) < _eps ) return true; else return false; } inline double rounder( double x , double _eps ) { int after_point = x - ( int )x; for( register double i = _eps ; i < 1.0 ; i += _eps ) if( after_point < i ) return ( int )x + i - _eps; return ( int )x + 1.0; } inline bool compare( Line a , Line b ) //sortµÄÅÐ¶Ï { if( cmp( a.l , b.l , 1e-8 ) ) return a.r < b.r; return a.l < b.l; } inline double TOT() //Ï߶β¢ { sort( line , line + n , compare ); double MaxL = mmin , MaxR = mmin , s = 0.0; for( register int i = 0 ; i < maxn ; i++ ) { if( line[ i ].r > MaxR ) { if( line[ i ].l > MaxR ) { s += MaxR - MaxL; MaxL = line[ i ].l; MaxR = line[ i ].r; } else MaxR = line[ i ].r; } } //printf( "TOT=%lf\n" , s + MaxR - MaxL ); return s + MaxR - MaxL; } inline double func( double height ) //·µ»ØÏ߶β¢ { for( register int i = 0 ; i < n ; i++ ) { line[ i ].l = a[ i ].l( height ); line[ i ].r = a[ i ].r( height ); } return TOT(); } inline double simpson( double l , double r ) //ÐÁÆÕÉ­ { return ( func( l ) + 4.0 * func( ( l + r ) / 2.0 ) + func( r ) ) / 6.0 * ( r - l ); } double Simpson( double l , double r , double EPS ) //×ÔÊÊÓ¦ { double mid = ( l + r ) / 2.0; //l = rounder( l , EPS ); //r = rounder( r , EPS ); //mid = rounder( mid , EPS ); double simp = simpson( l , r ); double simpl = simpson( l , mid ); double simpr = simpson( mid , r ); //printf( "l=%lf,r=%lf,simp=%lf,tot=%lf,eps=%lf,%s\n" , l , r , simp , simpl + simpr , EPS , cmp( simpl + simpr , simp , EPS ) ? "Accept" : "Failed" ); if( cmp( simpl + simpr , simp , EPS ) ) return simp; else return Simpson( l , mid , EPS / 2.0 ) + Simpson( mid , r , EPS / 2.0 ); } inline void read() { scanf( "%d" , &n ); for( register int i = 0 ; i < n ; i++ ) { scanf( "%d%d%d" , &a[ i ].x , &a[ i ].y , &a[ i ].m ); if( a[ i ].y < L ) L = a[ i ].y; if( a[ i ].y + a[ i ].m > R ) R = a[ i ].y + a[ i ].m; } } int main( void ) { read(); printf( "%0.1lf" , Simpson( L , R , eps ) ); } ```
by SisconHL @ 2020-01-10 12:32:26


...诶注释怎么回事
by SisconHL @ 2020-01-10 12:36:49


去你的妹子
by Register @ 2020-01-10 12:38:47


是妹子全家都死光
by Register @ 2020-01-10 12:39:15


@[wzsCD](/user/127284) @[songhaoran](/user/80679) 您们不帮我帮我调又说风凉话什么意思啊/kk
by SisconHL @ 2020-01-10 12:39:51


一天到晚给我还好意思说是妹子
by Register @ 2020-01-10 12:41:29


~~去哪打毛线帽子~~
by YLZZZ @ 2020-01-10 12:45:00


太强了些这种神仙题
by zmx_wzx_JY @ 2020-01-10 12:45:37


我现在码最小差值生成树码字20分调试两小时。
by zmx_wzx_JY @ 2020-01-10 12:46:17


@[avenLJY](/user/86579) 窝去年就在打P1222了
by SisconHL @ 2020-01-10 12:47:05


| 下一页