2012-01-01から1年間の記事一覧

続・PFIサマーインターン2011問題

今更ですが、これの続き。 前回は最悪がO(n2)だったので、最悪をO(n)にしました。 #include <assert.h> #include <algorithm> #include <string> char pfi2011(std::string& s) { assert(!s.empty()); typedef std::string::iterator iter_t; iter_t l = s.begin(), r = s.end(); iter_t c</string></algorithm></assert.h>…

C++で円周率を取得する

Boost.Math 円周率を取得する 普通に逆三角関数を使うのがいいんじゃないでしょうか。 #include <cmath> using std::acos; using std::asin; using std::atan; using std::atan2; int main() { double const pi1 = acos(-1.0); double const pi2 = 3*acos(0.5); dou</cmath>…

ステルスマーケティング

日本語入力を支える技術という本が今日発売されるらしいです。

Perlで多倍長計算

以下の手順を踏むと、PerlでGMPを使った多倍長計算ができます。まず Math::BigInt::GMP をインストールします。 cpan Math::BigInt::GMP Perlスクリプトに use bignum lib => 'GMP'; と書くと、自動的にGMPで多倍長計算されます。整数だけ使うなら: use big…