2009-02-08
SRM356 Div1 Easy: AverageProblem
- 丸め誤差に泣く問題。再投稿×2
class AverageProblem {
public:
int numberOfParticipants(vector<string> marks) {
set<int> s;
tr(marks,it){
vector<string> m_ = split(*it);
tr(m_,jt) s.insert((int)(1000 * atof(jt->c_str()) + 0.5));
}
for(int ps=1;;ps++){
set<int> s_;
double u = 1000.0 / ps;
for(int i=0;i<=ps*10;i++)
s_.insert((int)(u*i+0.0000001));
tr(s,it) if (!found(s_,*it)) goto next;
return ps;
next:;
}
}
};
コメント
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090208