SRM513 Div1 Easy(250), Div2 Medium(500) YetAnotherIncredibleMachine
それぞれのplatformについて何通りの置き方があるか求めて、掛け合わせる。
#include <vector> #include <algorithm> using namespace std; class YetAnotherIncredibleMachine{public: int countWays( vector <int> platformMount, vector <int> platformLength, vector <int> balls ) { long long M = 1000000009; long long ans = 1; for ( int i=0; i<(int)platformMount.size(); i++ ) { int c = 0; for ( int j=platformMount[i]-platformLength[i]; j<=platformMount[i]; j++ ) { bool f = true; for ( int k=0; k<(int)balls.size(); k++ ) if ( j<=balls[k] && balls[k]<=j+platformLength[i] ) f = false; if ( f ) c++; } ans *= c; ans %= M; } return (int)ans; }};