2010-12-01から1日間の記事一覧

SRM489 Div1 Easy(300) BallsConverter

BallsConverterボールが3個の場合について試せば良い。(a+b)+c=a+(b+c)が成り立つならばa+b+……+zが一意になるのと同じことで数学的帰納法で証明できる、らしい。わかるようなわからないような……。 #include <string> #include <vector> using namespace std; class BallsCon</vector></string>…

SRM489 Div2 Medium(500) BuyingFlowers

BuyingFlowersrosesの要素数が小さいので全ての組み合わせを試すことが可能。バラとユリの個数の違いはR*Cが偶数ならば0、奇数ならば1。それぞれの面積に対して|R-C|の最小値を事前に求めておく。 #include <vector> #include <numeric> using namespace std; class BuyingFlo</numeric></vector>…

SRM489 Div2 Easy(250) BadVocabulary

BadVocabulary #include <string> #include <vector> using namespace std; class BadVocabulary{public: int count( string badPrefix, string badSuffix, string badSubstring, vector <string> vocabulary ) { int ans = 0; for ( vector<string>::iterator v=vocabulary.begin(); v!=voca</string></string></vector></string>…

SRM489 Div1 Medium(500) DiceRotation

DiceRotationDPなどで小さなgoalx,goalyについて調べると法則が見える。 class DiceRotation{public: int theCount( int goalx, int goaly ) { int ans = 0; if ( goalx == 4 ) ans += goaly + 1; if ( goaly == 4 ) ans += goalx + 1; if ( goalx >= 2 && g…