2010-06-18から1日間の記事一覧
ChildlessNumberskを整数として、X=kYとなるXのみ調べる。 Y = kY/D(kY) ⇔ k = D(kY) ≦ 9 log10kY = 9 log10k + 9 log10Y なので、k<200 程度で充分。 class ChildlessNumbers { int D( long long n ); public: int howMany( int A, int B ); }; int Childle…
SequenceOfCommandsコマンドを実行して、向きを変えているか移動していなければ良い。 #include <string> #include <vector> #include <numeric> using namespace std; class SequenceOfCommands { public: string whatHappens( vector <string> commands ); }; string SequenceOfCommands::wh</string></numeric></vector></string>…
OnTheFarmDivTwo #include <vector> using namespace std; class OnTheFarmDivTwo { public: vector <int> animals( int heads, int legs ); }; vector <int> OnTheFarmDivTwo::animals( int heads, int legs ) { vector<int> ans; ans.push_back( 2*heads - legs/2 ); ans.push_bac</int></int></int></vector>…
起きたら既に始まってた。
Flag 2条件から旗は2列ごとの繰り返しになるので、偶数列と奇数列の色を用いて動的計画法。色数をcとして、O(nc2(m+c2))。C++ならば充分だけど、Pythonでは間に合わない。 id:pes_magic さんにオーダーを下げる方法を教えてもらいPythonでも通った。 Python…