TopCoder High School SRM 19 Level one - 250 pt - Dart Throw editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm19
TopCoder High School SRM 19 Level one - 250 pt - Dart Throw solution:
#include <iostream> #include <vector> using namespace std; class DartThrow { public: double bestScore(vector <int> py, int pr) { double cnt=0, ma=0, a; a=(double)pr/100; for(int i=0; i<py.size(); i++) { if(i==0) cnt=a*py[i] + (1-a)/2*py[(i+1)%py.size()] + (1-a)/2*py[py.size()-1]; else cnt=a*py[i] + (1-a)/2*py[(i+1)%py.size()] + (1-a)/2*py[(i-1)]; if(cnt>ma) ma=cnt; } return ma; } };
No comments:
Post a Comment