前の月 / 次の月 / 最新

~matubara/ChangeLog / 2006-05移動しました

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
2005 : 01 02 03 04 05 06 07 08 09 10 11 12

2006-05-31 Wed

可変長引数 K&R と ANSI [cxx]

Solaris の CC /usr/ucb/cc は K&R らしい。

K&R


int
sendf(va_alist) va_dcl
{
    static char buf[10240];                     /* xxx, enough? */
    SOCKET s;
    const char *fmt;

    va_list args;
    va_start( args );
    s = va_arg( args, SOCKET );
    fmt = va_arg( args, char * );


ANSI
int
 sendf(SOCKET s, const char *fmt...)
{
    static char buf[10240];                     /* xxx, enough? */

    va_list args;
    va_start( args, fmt );
    

Meadow で emacs-w3m [win][linux]

emacs-w3m 自体は、Meadow配布に含まれている。
あとは、w3m のパスを教えてやる。

(push (expand-file-name "e:/programs/cygwin/bin") exec-path)

として、Cygwin のなかにインストールされている w3m へのパスを通す。

(load-library "w3m")

も要ります。

Cygwin emacs で anthy [win][emacs]

anthy のデフォルトインストール先は /usr/local/emacs/site-lisp/
load-path にそこを追加しておけば

(push "/usr/local/share/emacs/site-lisp" load-path)

関数は使える。
けれど、肝心の anthy-mode, japanese-anthyのinput-methodが使えない。
しょうがないので、
/usr/local/emacs/site-lisp/anthy
<- /usr/share/emacs/site-lisp/anthy へのリンクを張ったら動いた。

Japanisch-Deutsches Kanji-Lexikon - Hans-Jörg Bibiko 2006 [lx][net]

<http://www.bibiko.de/kanji/>
grapheme-base の検索をサポートしている。

2006-05-30 Tue

Life with Cygwin [linux][win][net]

<http://www.okisoft.co.jp/esc/cygwin.html>
Cygwin 関係のチュートリアル。
Emacs とか日本語とか説明が丁寧。

Cygwin/X の設定 [linux][win]

xorg.conf とかはない けど、
X 起動のときのオプションでいくらか設定できる。

startx -- -fp "/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/TTF/,/usr/X11R6/lib/X11/fonts/Type1/,\
/usr/X11R6/lib/X11/fonts/75dpi/,/usr/share/fonts/mplus" -multiwindow -emulate3buttons -clipboard
フォントパス追加と、XアプリケーションウィンドウのWindowsへの透過と、
クリップボートからの貼り付け、クリップボード共有

M+ fonts を Meadow で使う [emacs][font][win]

解像度低めで小さいディスプレイだと見やすい。

(w32-add-font
 "BDF M+"
 '((strict-spec
    ((:char-spec ascii :height any)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_f12r.bdf"))
    ((:char-spec ascii :height any :weight bold)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_f12b.bdf"))
    ((:char-spec ascii :height any :slant italic)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_f12r.bdf"))
    ((:char-spec ascii :height any :weight  bold :slant italic)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_f12b.bdf"))
    ((:char-spec japanese-jisx0208 :height any)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_j12r.bdf"))
    ((:char-spec japanese-jisx0208 :height any :weight bold :slant any)
     (bdf-font "e:/programs/meadow/bdf/mplus/mplus_j12b.bdf")))))
(set-default-font "BDF M+")

2006-05-27 Sat

ChangeLog Merger [perl][chalow]

sort + uniq 機能つき。

#! /usr/bin/env perl
use warnings;
use strict;

my @articles = (); # [id(date+author), begin, end]
my @lines = <>;

# collect ids and begins
for my $i (0 .. $#lines) {
    if ( $lines[$i] =~ m/^(\d\d\d\d-\d\d-\d\d\s+.*)$/ ) {
        push @articles, [$1, $i, ];
    }
}

# collect ends
for my $i (0 .. $#articles-1) {
    $articles[$i][2] = $articles[$i+1][1]-1;
}
$articles[$#articles][2] = $#lines;

# collect lines
@articles = map [$_->[0], join('', @lines[ $_->[1]+1 .. $_->[2] ])], @articles;


# uniq
{
    my %h;
    foreach ( @articles ) {
        my $k = $_->[0];
        if ( exists $h{$k} ) {
            $h{$k}->[1] .= $_->[1];
        } else {
            $h{$k} = $_;
        }
    }
    @articles = values %h;
}

print
    map "$_->[0]\n$_->[1]",
    sort { - ($a->[0] cmp $b->[0]) } @articles;

2006-05-25 Thu

The TeX Catalogue OnLine, Topic Index [latex][net]

CTAN にある LaTeX のいろんなパッケージのカテゴリ分けされたリスト。
<http://www.ctan.org/tex-archive/help/Catalogue/bytopic.html>
csvtools とかある。

2006-05-24 Wed

Science and Engineering quotes [nlp]

There is the value of the worldview created by science...
The world looks so different after learning science.

(Feynman)

The world does look different after Engineering because you have changed the world.

(?)

via nlp blog: NLP is an Engineering Discipline?

conference ranking - Google Search [nlp][net]

<http://www.google.com/search?hl=en&q=conference+ranking&btnG=Search>
計算機科学関係の学会ランキング。

CofsDevice - coLinux [linux][win][net]

<http://wiki.colinux.org/mediawiki/index.php/CofsDevice>

<cofs_device index="0" path="\DosDevices\c:\" type="flat" enabled="true" />

in your colinux.xml.

Now you can mount this virtual device with

  mount cofs0 /mnt/MYMOUNTPOINT -t cofs -o ro

2006-05-23 Tue

.forward でメールを加工 [mail]

.forward には転送先の代わりに、コマンドを書くことができ、
転送するかわりに、メールを標準入力に与えてそのコマンドを起動できる。
書式は /etc/aliases の : より右と共通で、
Postfix manual - aliases(5)

|"/usr/bin/vacation matubara"

とかいう感じ。

\matubara
|"perl -pe's/^To: /To: matubara, /' | /usr/lib/sendmail x@gmail.com"
まず、matubara にそのまま配送し、
次に、To: に自分のアドレスを追加して、x@gmail.com に転送。

mbox からの最近のメール抽出と転送 [howto]

tail -XXX /var/spool/$USER >mbox

で、欲しい部分を切り出す。
From: で始まるようにXXXを調整。

cat mbox | \
formail -s perl -pe's/^To: /To: tsujii\@is.s.u-tokyo.ac.jp, /' | \
formail -s sendmail -v -f root matsubaray@gmail.com

mbox中のメールの転送 [mail][net]

<http://search.luky.org/linux-users.6/msg04943.html>
formail というツールが適しているらしい。

formail -s sendmail xxx@yyy

で、標準入力に入れられた mbox をばらしてメールとして送ってくれる。

reStructuredText -> LaTeX [markup][latex]

Wiki っぽい簡単なマークアップから、LaTeX ソース(など)への変換ができる。
この手のツールの中では、一番広く使われている感じ。

とりあえず、docutils と、
rst-mode.el を入れて、
Meadow/Emacs memo -- ロードパス
を参考にして、load-path が通ってるところ
(/usr/share/emacs/site-lisp で多分大丈夫) に .el を置いて、

(require 'rst-mode)

と書く。

rst2html.py xxx.txt > xxx.html

Using Random Forests in the Structured Language Model [lm][net]

<http://www.clsp.jhu.edu/people/xp/publications/nips04.pdf>
構文的な特徴を取り込んだN-gram的言語モデル。
構文木の部分木を使って、単語の列を、単語と支配主辞のペアの列に変換する、とか。
まだよく分かってない。
ベースは、Structured Language Model

Mark Lyon's GMail Loader (GML) - Import Your Mail into GMail [mail][net]

<http://www.marklyon.org/gmail/>
ローカルにある mbox か MailDir の内容を、GMail のアドレスに送信する。
データ移行のツール。

Thunderbird は mbox なので、
Thunderbird で移行元のメールを受信(File -> Offline -> Download/Sync now)
して、%PROFILE%/ImapMail/xxx.ac.jp/yyy
というファイルをこのツールで読み込む。

SMTPで送ってるので、
@以降を省略したアドレスは、書き換わってしまう。
もともとのサーバー上で実行するか、ファイルを加工しておく必要がある。

GMail が(たぶん Message-Id を見て)重複メールの受信を回避しているので、
転送しているメールなどを適当に送ってもダブりがあまり起きない。

2006-05-22 Mon

\usepackage{fullpage} [latex][net]

<http://www.tug.org/tex-archive/macros/latex/contrib/preprint/fullpage.dtx>

% Call as \usepackage[options]{fullpage}
% Options = in (default) for 1 inch
% cm for 1.5 cm
% plain (default) sets \pagestyle{plain}
% empty sets \pagestyle{empty}
% headings sets \pagestyle{headings}
% myheadings sets \pagestyle{myheadings} 

LaTeX2e209 で margin を小さくするパッケージ。

2006-05-21 Sun

JSAI SIG-DMSM [stat][learning][net]

<http://www.med.shimane-u.ac.jp/med_info/sig-dmsm/>
人工知能学会の「データマイニングと統計数理研究会」
第一回は7月11日統数研で。

Publications -- 持橋大地 [lm][stat][people][net]

<http://chasen.org/~daiti-m/paper/>

Syntactic Theory -- instructors manual for the second edition [nlp][lx][book][net]

<http://hpsg.stanford.edu/book/slides/index.html>

Syntactic Theory: a formal introduction,
Second Edition
Instructor's Manual
Emily M. Bender, Ivan A. Sag, Thomas Wasow

スライドが置いてある。

2006-05-20 Sat

Windows の日本語フォントを簡単にアンチエイリアス [win][howto][font]

Cygwin 用の FontForge を使う。
対象のTTFファイルを開き、ビットマップなしの OpenType フォントとして出力。
出力時のオプションで、「整数値」にしておくとサイズが少なめ。

(ビットマップなしのTTFファイルとして出力しても、なぜか小さいサイズではアンチエイリアスなし)


Unicode フォントはうまく変換できなかった。

2006-05-19 Fri

Bayesian Hierarchical Clustering (2004, ICML) [lm][ir][algorithm][net]

<http://citeseer.ist.psu.edu/735303.html>
ボトムアップクラスタリングの距離評価に、
Bayesian なモデルによる確率を使う。

Katsurada Labo. Text [math][algorithm][book][net]

<http://www.math.meiji.ac.jp/~mk/labo/text/>
線形計算とか、関数解析などのノート、というか本に近い。

格フレーム検索@京大黒橋研 [nlp][net]

<http://reed.kuee.kyoto-u.ac.jp/cf-search/>
Web から抽出された格フレーム辞書の検索。
用例へのリンクつき。

複合辞 として使われる用言を調べると面白い。
複合辞は意味が非構成的になる複合用言のことで、
たとえば「〜にとって」とか。

「ある」「いる」「する」「とる」「かける」などは複合辞を構成する。

ソースがWebなので、
「見る」「叫ぶ」を検索すると、
「ガ格:マリア」「ヲ格:愛」などが出てくる。

2006-05-17 Wed

SVDPACK [math][algorithm][nlp][net]

<http://www.netlib.org/svdpack/>
潜在意味解析 Latent Semantic Analysis に使う 特異値分解 Singular Value Decomposition のパッケージ。
論文相当の User's guide 付き。

特異値は非正方行列に対して定義される固有値のようなもので、
A trans(A)の固有値の平方根と等しい。
特異値分解は、固有値分解=直交行列による対角化に対応する。

特異値の大きい方からいくつかだけで特異値分解を近似すると、
次元の圧縮を行うことができる。
そのようなとり方によって、二乗誤差が最小になることが分かっている。

2006-05-16 Tue

物理のかぎしっぽ [math][phys][net]

<http://www12.plala.or.jp/ksp/index.html>
物理、数学系の軽めのガイドがたくさん書かれている。
reStructuredText -> (LaTeX) -> PDF なツール kagiPDF もある。
コンピュータ - [物理のかぎしっぽ] も便利なソフトウェアの紹介があり、参考になる。

coLinuxのメモ - coLinuxのインストール (TAP-Win32でのNAT接続) [linux][win][net]

<http://scratchpad.fc2web.com/colinux/install/install-5-1.html>
要点は、
ホスト(Windows)側の実際のネットワーク接続を「共有」にし、
coLinux で DNS をただしく指定すること。

coLinux の設定ファイルは次のような感じ。

<?xml version="1.0" encoding="UTF-8"?>
<colinux>
    <!-- This line needs to point to your root file system. 
 For example change "root_fs" to the name of the Debian image.
 Inside coLinux it will be /dev/cobd0 
 
 Block Device Aliasing: You can now handle most dual-boot issues
 by adding an alias="devname" to block_device. i.e. alias="hda",
 alias="hda1" You can do this for SCSI as well as IDE.  You need
 to be aware that if you add an alias, you need to change your
 bootparams root="devname" appropriately (you may need to use
 devfs naming in some situations).  -->
    <block_device index="0" path="\DosDevices\e:\programs\coLinux\root_fs" enabled="true" />
    
    <!-- This line can specify a swap file if you wish, or an additional
 image file, it will /dev/cobd1. Additional block_devices can
 be specified in the same manner by increasing the index -->

    <block_device index="1" path="\DosDevices\e:\programs\coLinux\swap_device" enabled="true" />

    <!-- This is an experimental feature, it may not function completely.
    <cofs_device index="0" type="flat" path="\DosDevices\C:\" enabled="true" />
    -->

    <!-- bootparams allows you to pass kernel boot parameters -->
    <bootparams>root=/dev/cobd0</bootparams>

    <!-- Initial RamDISK (initrd) support -->
    <initrd path="initrd.gz" />
    
    <!-- image allows you to specify the kernel to boot -->
    <image path="vmlinux" />

    <!-- this line allows you to specify the amount of memory available 
 to coLinux -->
    <memory size="64" />

    <!-- This allows you to modify networking parameters, see the README 
 or website or wiki for more information -->
    <network index="0" type="tap" name="TAP" />
</colinux>

root_fs は配布されているディスクイメージを展開したファイル。
ファイル名や置き場所も、coLinux 直下の root_fs とするのが無難っぽい。
swap_device は

fsutil file createnew swap_device 268435456

で作る。
fsutil file createnew root_fs2 8589934592

emacs current directory [emacs]

(setq default-directory "e:/mydoc/")

Modeling word burstiness using the Dirichlet distribution [ir][lm][stat][net]

<http://portal.acm.org/citation.cfm?id=1102420>
Dirichlet分布を使った文書モデル。
単語頻度の経験的分布において、
多項分布によって表すことができない性質があることを示し、
それを Dirichlet 分布で表すことができることを示す。
(明らかに傾向が違う)

多項分布モデル(単語頻度だけの Vector Space Model)は良くないが、
Vectorの作り方を TFIDF などログスケールにした場合はよくなる。
Dirichletモデルは、そのようなヒューリスティクスを使わなくても、近い性能が出る。
(というか最初から対数線形…)

双方を改善するヒューリスティクス(先行研究):
Complement modeling (complement training) は、
あるクラスに対象が属する確率を、属しないデータを使って推定する。
属するデータより属しないデータの方が多いから有効?

Dirichlet 分布モデルの論文の中で、一番分かりやすかった。

2006-05-15 Mon

Bernhard Korte and Jens Vygen, 組み合わせ最適化 理論とアルゴリズム [math][opt][book]

読んでない。

2006-05-13 Sat

A tutorial on Learning Dynamical Systems [math][stat][chaos][net]

<http://www.cs.brown.edu/research/ai/dynamics/tutorial/>
Mathematica による動的システムのチュートリアル、演習。
グラフィカルモデルと学習もあり。

Ruby/CHISE [nlp][font][net]

<http://eto.com/2003/ruby/index.html.ja>
Unicode Ideographs の字形分解、字形合成のインターフェース。

"森".decompose_all

とかできるらしい。

emacs keybindings in shell-mode [emacs]

Emacsの上部メニューにも結構載ってる。

C-c C-c

send INTERRUPT

C-c C-\

send QUIT

C-c C-o

delete the last output

M-p

the previous command

C-c C-p

move to the line of the previous command

C-c RET

copy and paste the pointing command

2006-05-12 Fri

C one-liner [cxx]

#! /bin/bash
echo $1 > /tmp/col-$$.c
gcc /tmp/col-$$.c -o /tmp/col-$$.o \
  && /tmp/col-$$.o
rm /tmp/col-$$.o /tmp/col-$$.c

include が使えないけど。

col 'main(){puts("test");'}

one-liner Fibonacci [perl][ruby]

perl -e '$x=0;$y=1; ($x,$y)=($y,$x+$y)for(1..<>); print"$x\n"'
ruby -e 'x=0;y=1; gets.to_i.times{y=x+y;x=y-x}; p x'

Ruby の方が短い。

2006-05-11 Thu

const_cast<> [cxx]

const をなくすキャスト。
(実行時には書き込むとSegmentation Fault)

#include <cstdio>


char * f(char * s)
{
  puts(s);
  s[0] = '\0';
  return s;
}

int main(int argc, char ** argv)
{
  const char * s = "cc";
  f(const_cast<char *>(s));
  return 0;
}

2006-05-10 Wed

Indo.to 日本×インドポータルサイト(インド・トゥ) [ethno][net]

<http://indo.to/>

環境変数TEXINPUTS - 物理のかぎしっぽ [latex][win][howto][net]

<http://hooktail.org/computer/index.php?%B4%C4%B6%AD%CA%D1%BF%F4TEXINPUTS>

TEXINPUTS = .;C:/xxx/xxx/mytex//;

ポイントは、カレントディレクトリを入れること、
区切りは;であること、
各ディレクトリの最後は//で終わること。←「再帰的」の意味らしい。

2006-05-09 Tue

${FIREFOX_PROFILE}/user.js [chalow]

Copy URL+ という Firefox 拡張で、ChangeLog形式にコピーするためのスクリプト片。

user_pref('copyurlplus.menus.1.label', 'Title [net]: <URL> >>Sel<<');
user_pref('copyurlplus.menus.1.copy', "%TITLE% [net]:\n	<%URL%>\n	>>%SEL%\n	<<");
user_pref('copyurlplus.menus.2.label', '[[Title|URL]]');
user_pref('copyurlplus.menus.2.copy', "[[%TITLE%|%URL%]]");

Data Clustering -- A Review - Jain, Murty, Flynn (1999) [nlp][algorithm][net]

<http://citeseer.ist.psu.edu/jain99data.html>
Clustering のサーベイ。

@IT:連載 改訂版 C#入門 [cxx][net]

<http://www.atmarkit.co.jp/fdotnet/csharp_abc2/index/>

C++ Annotations Version 6.2.4 [book][cxx][net]

<http://www.icce.rug.nl/documents/cplusplus/cplusplus.html>
Self-contained な本。
C の基本構文の部分などは省かれている。

Sites of interest to C++ users [cxx][net]

<http://www.robertnz.net/cpp_site.html>

STL Error Decryptor for C++ [cxx][net]

<http://www.bdsoft.com/tools/stlfilt.html>
C++ コンパイラが出すエラーメッセージを解読してくれる
という、ジョークなのかどうかよく分からないプログラム。

C/C++ Reference [cxx][net]

<http://www.cppreference.com/>
Minimalist なリファレンス。

Perfect Matchings And Perfect Powers - Ciucu (2003) [math][net]

<http://citeseer.ifi.unizh.ch/ciucu03perfect.html>
格子状に区切られた平面を、2マスのタイルで敷き詰める……
完全マッチングの数を数える問題。
[2006-05-01-4]

Spectral Based Information Retrieval [math][nlp][ir][net]

<http://www.ee.unimelb.edu.au/multimedia/research/cubin_Laurence_Park_SpectralPhD.pdf>
DCT x IR

基本に使う情報が、単語の頻度ではなく空間周波数。
どっちも Frequency なのはご愛嬌。

slides

質問単語と文書の類似度を、
その単語のその文書における空間周波数スペクトルの大きさと角度を使って決める。
質問の中のすべての単語について、大きさと角度のそれぞれの平均をとる。
その平均スペクトルにおいて、角度を大きさで重み付け和をとった値を、
類似度とする。

これが Fourier Transform Model による IR。
性能は良いが、まだちょっと遅いので、
FFTをDCTで近似する方法を提案し、
速度と性能を両立するWavelet Transform バージョンを提案する。

DCTは高周波領域の情報を落としたスペクトルを使う近似法。

…というのが、スライドの内容でした。

面白いけど、ほんと?

2006-05-08 Mon

emacs keybindings [emacs][linux]

M-g M-g

goto line

C-o

insert a blank line

C-x C-o

uniq blank lines after here

? (in mini-buffer)


C-x `

goto error

2006-05-07 Sun

The Elements of Statistical Learning, Hastie, Tibshirani and Friedman (2001) [stat][learning][book][net]

<http://www-stat-class.stanford.edu/~tibs/ElemStatLearn/>
0387952845
Manning & Schultze よりも、Jurafsky & Martin + Hastie et alとの評を見て。

例によって、経済学部図書館にある。

Shane Legg [people][stat][net]

<http://www.idsia.ch/~shane/>
AIと統計的学習と遺伝的アルゴリズム。

Parsing Techniques - Second Edition [algorithm][book][net]

<http://www.cs.vu.nl/~dick/PT2Ed.html>
(プログラミング言語を中心にした)構文解析の本。

The Assayer [book][math][net]

<http://theassayer.org/>
Free テキストとドキュメントの注釈つきリンク集。
特に、数学のテキストが多い。

2006-05-06 Sat

S@CO --- seminar on advanced computation and optimization [math][net]

<http://www.me.sophia.ac.jp/~s-morigu/s@co/mirai.html>

2006-05-04 Thu

Bayesian Methods for Natural Language Processing / NIPS 2005 [stat][nlp][net]

<http://www.isi.edu/~hdaume/BayesNLP/>
Bayesesian NLP の(現在のところ)の総本山?
Resourcesと、
Participants から辿れる論文はReading List。
熟読すべし。

Linguistics Meta-Index [nlp][lx][net]

<http://www-nlp.stanford.edu/links/linguistics.html>
(計算|)言語学のサイトのリスト。
Manning 先生による。

CS 224N / Ling 280 ― Natural Language Processing [nlp][net]

<http://www.stanford.edu/class/cs224n/syllabus.html>
FSNLP の Manning 先生の授業。
資料が多く公開されている。
今年も開講中。

ICML 2006 Workshop on Learning with Nonparametric Bayesian Methods [stat][learning][net]

<http://www2.informatik.hu-berlin.de/~bickel/npb_workshop.html>
Dirichlet Process とか。

2006-05-02 Tue

Michael I. Jordan's Home Page [people][math][lm][stat][net]

<http://www.cs.berkeley.edu/~jordan/>
Hirarchical Dirichlet Process の人。

David M. Blei [people][math][lm][stat][net]

<http://www.cs.princeton.edu/~blei/>
Latent Dirichlet Allocation の人。

Plagger インストール [perl]

cpanで

install Plagger


依存関係で入るモジュールについて色々聞かれる。
ほっとくとタイムアウトで落ちるっぽい。
辛抱強く答えていったら、インストールできた。

Developing applications with Objective Caml [programming][book][fp][net]

<http://caml.inria.fr/pub/docs/oreilly-book/>
700ページくらいあるOcamlの本。

雅 % less ~miyabi/knowhow/memo.txt [people][net]

<http://miyabi-phd.lolipop.jp/diary/index.html>
K君の指導教官N先生。

2006-05-01 Mon

Tri tiling [programming][net]

<http://acm.pku.edu.cn/JudgeOnline/problem?id=2663>
いまだに、まともにDPが書けません。
これはMemoiseという(?)

#! /usr/bin/env perl
use strict;
use warnings;

use constant CELL       => 0;
# ..++
#   ++++
# ..++++
#     ^n

use constant HORIZONTAL => 1;
# ..
#   ++++
# ..++++

use constant VERTICAL   => 2;
# ..++
#   ++
# ..++++

use constant NOTHING    => 3;
# ..++++
#   ++++
# ..++++

my @table =  ();

sub count($$);
sub count($$)
{
    my($piece, $n) = @_;

    my $prog = sub {
#    print STDERR ["e", "H", "V", "P"]->[$piece], " $n\n";
return 1 if ( $n == 0  &&  $piece == NOTHING);
return 1 if ( $piece == CELL  &&  $n == 1 );
return 0 if ( $n <= 1 );

if ( $piece == HORIZONTAL ) {
    return count(VERTICAL, $n-2) + 2 * count(NOTHING, $n-2);
} elsif ( $piece == VERTICAL ) {
    return count(CELL, $n-1);
} elsif ( $piece == CELL ) {
    return count(NOTHING, $n-1) + count(VERTICAL, $n-1);
} elsif ( $piece == NOTHING ) {
    return count(HORIZONTAL, $n) + count(VERTICAL, $n);
}
    };
    if ( !defined $table[$piece][$n] ) {
$table[$piece][$n] = $prog->();
    }
    return $table[$piece][$n];
}

while (<>) {
    chomp;
    last if ( $_ == -1 );
    print count(NOTHING, $_), "\n";
}

2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
2005 : 01 02 03 04 05 06 07 08 09 10 11 12

最終更新時間: 2009-02-01 00:57

Powered by chalow
inserted by FC2 system