2009-11-17から1日間の記事一覧

PKU 1016 Numbers That Count

PKU

Numbers That Count #include <iostream> #include <string> using namespace std; string invent( string w ); int main() { string w; while ( cin >> w && w != "-1" ) { string seq[16] = { w }; for ( int i=1; i<=15; i++ ) seq[i] = invent( seq[i-1] ); int j, k; for </string></iostream>…

PKU 1015 Jury Compromise

PKU

Jury Compromise動的計画法の使い方がわかってきた。 D(J)-P(J) の取り得る値が高々±20nなので、m人の候補を組み合わせて D(J)-P(J)=i となりうるかどうかを表の i 番目のセルに持つ。複数ある場合は D(J)+P(J) が最大となるようにすることで、最適な組み合…

SRM453 Div1 Easy(250) TheBasketballDivOne

TheBasketballDivOneチーム数 n≦5 なので試合結果 3n(n-1)/2 は最大59049通り。全パターン試す。 #include <iostream> #include <set> #include <vector> using namespace std; class TheBasketballDivOne { public: int find( int n, int m ); }; int TheBasketballDivOne::find( i</vector></set></iostream>…