2008-12-26
SRM389 Div1 Easy: ApproximateDivision
簡単。
class ApproximateDivision { public: double quotient(int a, int b, int terms) { int t=1; while(1){ if(t<b) t*=2; else break; } int c=t-b; double d=0, e=1.0/t, r=1.0*c/t; rep(i,terms) {d+=e; e*=r;} return d*a; } };
コメント
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20081226