2011-02-12から1日間の記事一覧

srm 494 dim2 easy InterestingDigits

自分の使っているtopcoderヘルプツールで自動生成されるコードでは、実装対象のクラスオブジェクトがmainの自動変数として宣言されていることに気付かずちょっとはまった。 #include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <iostream> #include <utility> #include <set></set></utility></iostream></algorithm></map></vector></string></sstream>…

srm 150 div2 mid InterestingDigits

#include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <iostream> #include <utility> #include <set> #include <cctype> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; class InterestingDigits{ pub…</cmath></cstdlib></cstdio></stack></queue></cctype></set></utility></iostream></algorithm></map></vector></string></sstream>

srm 490 div2 mid Starport

int型からはみ出してしまって撃沈 -> longに修正 このコードだと、N=1e9, M=1 でタイムアウトになるみたい。 whileループがN回(i.e. 1e9回)のループになっちゃう。 それ以前に、N=1000000000, M=999999999 でおかしな値が出ているな。 この問題は、それなり…

srm 482 div2 easy AverageAverage

ビット演算の練習 ビット演算は優先順位がとても低いらしい。 if(combi & (1 今回、関数名が思い出せなくて使わなかったけど__buildin_popcountという関数があるらしい。 空でない組み合わせの数は n C m - 1 なので、注意。 各数字に対して使うか使わないか…

srm 478 dim2 easy KiwiJuiceEasy

仮引数書くのが面倒だったのでポインタにしたら余計面倒だった。 #include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <iostream> #include <utility> #include <set> #include <cctype> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> using namespace st…</cmath></cstdlib></cstdio></stack></queue></cctype></set></utility></iostream></algorithm></map></vector></string></sstream>

srm 464 dim2 easy

割と素直な方針で提出したんだけど、システムテストで撃沈。どこでバグっているのか不明。 昼休みに直そうと思ったけど、コード紛失。

srm 480 div2 easy Cryptography

クラス Cryptography 整数リストが与えられる。その中から一つだけを選んで+1する時、結果のリストの積を最大にするには? 一番小さい数をインクリメントして積を返す これくらいの問題サイズなら全列挙しても良い。 red coderでも全列挙している人多し。 面…

topcoder養成講座第2回

メモ 便利リンク http://www.otinn.com http://iajust3.scm.ca/tcstats 目安として、1億回の演算くらいなら2秒で終わる でかい数の掛け算は、overflowに注意。