2008-10-01から1ヶ月間の記事一覧

Problem 6

The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 55^2 = 3025 Hence the difference between the sum of the squares of t…

Problem 5

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest number that is evenly divisible by all of the numbers from 1 to 20? 標準ライブラリのlcmを使って一瞬 p005 = foldl…

Problem 3

The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ? 素因数分解した。 p003 = last.pfac$600851475143 pfac 1 = [] pfac m = q:(pfac m') where (q,m') = head [(n,div m n)|n<-[2..(floor.sqr…

Problem 2

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...Find the sum of all the even-valued terms in the sequence whi…

Problem 1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. 始めの問題だけあって簡単。手計算でできる。 p001 = sum …

無限リストを含むリストの型?

Haskellではリストは以下の3つに分けられる有限リスト [1,2,3,4] , [1,20,30] 無限リスト [1..] そして最後が擬リスト 例えば _|_,1:2:_|_, 10:20:30:40:50:_|_ 要するに、末尾がbotになっている。 上の二つのリストとの関係は擬リストの極限が無限リストと…

Problem 4

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.Find the largest palindrome made from the product of two 3-digit numbers. 速く動かすのに、意外と手こずった。…

マラソン

河口湖マラソンに申し込んだ。 締め切りぎりぎりだ。 今年は感想できるか、いや、完走だって、 使えねーな、このIME完走目指してがんばります。自己ベストは多分無理。 練習量が10分の1とかだから、30分の1かも・・・

haskell memo

h = 1:map (2*) h # map (3*) h # map(5*) h where xxs@(x:xs) # yys@(y:ys) | x==y =x:(xs#ys) | x<y =x:(xs#yys) | x>y =y:(xxs#ys) prime = let p (x:xs) =x:(p (filter ((/=0).(flip rem x)) xs)) in p [2..] fib = 0:1:[i+j|(i,j)<-zip fib $tail fib]</y>

halftone

import Data.Array.IArray import Control.Monad (liftM,replicateM) import System (getArgs) import System.Random (getStdGen,randomRs) type Picture = Array (Int,Int) Int step x | x < 0 = 0 | otherwise = 1 inv 0 = 1 inv _ = 0 threshold :: Pictu…

SPRINT

渡良瀬でスプリントのチーム・タイム・トライアルに出場。 総合記録は一時間20分ぐらい。 (ここからはVIPPER風で) スイム、とりあえず、最後尾からスタート、前の人が邪魔www 俺の前を横切るな、お前コースアウトだぞwww スイムフィニッシュ。結構疲…

Haskellで2制約ナップサック

{-- Time-stamp: <2008-10-11 15:24:47> ナップサック問題の動的計画法と分枝限定法 Usage: ./knapsack2.exe bb < knapsack_problem/problem ./knapsack2.exe dp < knapsack_problem/problem 入力データ使用 (アイテム数) (ナップサックの容量)(ナップサ…

LPの幾何的双対性

すごいきれいな関係がprimal,dualに成り立つことを知った。 これだから、数学は面白い。簡単に書くと以下。 ここで、で、は閉凸錘、はの双対錘。

スイム練

久しぶりに750mのタイムを計った。14分30秒。まぁ、こんなもんでしょ。 練習してないし、そもそも、いままでも、そんなに練習してこなかったわけだ。

WEP解読

前から、WEPは脆弱だ、ということは耳にしていたが どうやら非常に簡単に解読できる手法が発見されたらしい。 いま、ほとんどのところがWEPだと思われる。これからどうなるのか?http://gigazine.net/index.php?/news/comments/20081013_wep_morii/

とりあえず

卒論とは関係ないけど Haskellで行列をうまく扱えるようになろう。

Operaショートカット

[F9] キーボードフォーカスを得る [F8]アドレスバーをフォーカス [z]前のページに戻る [x]次のページに進む

Operaでメイリオ(Xp)

Operaだとメイリオで表示されないことがある。 そこで、 [設定]→[詳細設定]→[コンテンツ]→[スタイルオプション]→[表示モード] で「作成者モード」の「ユーザーフォントと配色」にチェックを入れ「表示設定」のユーザースタイルシートの場所に *{ font-family…

漫画

HUNTERxHUNTERと嘘喰い買った。

バイク練

ひさびさに荒川でバイク練。 しかし、世間は3連休で人が多くて走りづらかった。まぁ、いい運動になったよね。

カイジ

とりあえず、賭博破戒録カイジ 全巻読んだ。 カイジおもしろすぎww

2制約ナップサックとカイジ

思っていた以上に難しい。 何が難しいかというと、速く動くプログラムの作成。 まぁ、NP困難な問題だから、そんなに簡単に速いものはつくれない。 しかし、1制約は連続緩和を利用した分枝限定法がかなり高速に動作する。 それに比べ2制約は、連続緩和が利用…

HaskellでDP(2)

import Control.Monad.State (State,get,put,evalState) import Control.Monad import Prelude hiding(lookup) import Data.Map (Map,lookup,insert,empty) import IO import System import Data.List(sortBy) -- ====動的計画法==== type Table k v = Map k…

HaskellでDP

HaskellでDPを書いたが、復習に時間がかかり、結局DPしか書けなかった。 本当は分枝限定法も実装するつもりだったのに・・・終わらない・・・、時間がない。でも、分枝限定法はDPに終了判定を付加して、深さ優先で探索するようにしてやれば いいような気がす…

病院

昨日も今日も病院にお世話になっている。 なんか病弱になった?ちなみに今日は2研歓迎会があった。 なかなか面白かった。重要なのは”生きる力”だそうだ。たしかに。 最近の環境は温いから、いつ環境が激変するとも限らない。

swim

水泳したらまた体調がよろしくない。 これは運動するなという天の声(キリッ!

構造力学

わかんね 剛性とか仮想荷重とか 物理を勉強してこなかったツケかとりあえず、教科書がほしいです用語の定義が分からないとか、もうね、どうしようもないよ

研究室

きまった。テーマ決まらず。