2008-01-01ãã1å¹´éã®è¨äºä¸è¦§
http://projecteuler.net/index.php?section=problems&id=163 ä¸è§å½¢ã®æ°ãæ°ããç°¡åãªãä»äºã ãããªã«ç°¡åã§ã¯ãªããã m = 36 layer n = tail.concat $ [map (<+>(6*n-k,k)) grid| k<-[0,6..6*n]]++[[(6*(n+1),0)]] where grid = [(4,-2),(0,3),(0,6),(â¦
http://projecteuler.net/index.php?section=problems&id=164 ããã¯ç°¡åã表ãåããã ãã®ç°¡åãªãä»äºã import Data.Array m = 20 f = listArray ((1,0,0),(m,9,9)).map g.range $ ((1,0,0),(m,9,9)) where g (1,a,b) = 10 - (a+b) g (n+1,a,b) = sum[f!â¦
C++ã ã¨å®è¡æéã¯ã©ãå¤ããã®ã åãã¢ã«ã´ãªãºã ã§å®è£ ãã¦ã¿ã #include <iostream> #include <map> using namespace std; int h=12,w=9; int area[][3]={{0,w,w+1},{0,w,w-1},{0,w+1,1},{0,w,1},{0,w,2*w},{0,1,2}}; bool inBoard(int x,int t){ switch(t){ case 1: re</map></iostream>â¦
http://projecteuler.net/index.php?section=problems&id=161 ãã£ã¨è§£ããã import java.util.*; public class P161{ static Map<Board,Long> memo; static Board board; static int h=12,w=9; static long solve(int x){ if(memo.containsKey(board))return memo.get(</board,long>â¦
http://projecteuler.net/index.php?section=problems&id=161 解ããªããä»ã®æ¹é㯠ãããã¯ã«åå²ï¼e.g. 4x3 -> {1x3,3x3},{2x3,2x3}..) åãããã¯ã§åå²ä¸è½ãªã¿ã¤ãªã³ã°æ°ããã¨ãã(çµæãè¦ããåå©ç¨ï¼ ç·æ°ãèãã è¨ç®ãçµãããªã⦠ã¨ããããåâ¦
http://projecteuler.net/index.php?section=problems&id=162 çµã¿åããã®åé¡ã ãç°¡åã§ããã ãããããProblem 161 ã解ããªãã import Numeric import Data.Char f k = 15*16^(k-1) - (15^k+2*14*15^(k-1)-(2*14^k+13*14^(k-1))+13^k) main = putStrLâ¦
http://projecteuler.net/index.php?section=problems&id=160 éä¹ã®éé¶æ«å°¾ã®æ°åãkåæ±ããã n!ã«å«ã¾ãã5ã®æ°ãp(n)ã¨ãã㨠n!/10^p(n) mod (10^k) ãåããã°ããã ã¾ããn!/10^p(n) = 0 (mod 2^k) ã§ãããã n!/10^p(n) mod (5^k) ãæ±ãã¦ããâ¦
http://projecteuler.net/index.php?section=problems&id=159 mdrs(n) = max_{m*d=n}(mdrs(m) + mdrs(d)) ã¾ããæãç«ã¤ã§ããã import Control.Monad import Data.Array.IO lim = 10^6 main = do drs <- newListArray (2,lim-1).tail.cycle$[1..9] :: IO â¦
http://projecteuler.net/index.php?section=problems&id=158 çµã¿åããã®åé¡ choose n r = div (product [n-r+1..n]) $ product [1..r] p m n = (2^n-(n+1))*choose m n main = print.maximum.map (p 26) $ [0..26] è¦ç´ æ°mã®é åºéåããnåé¸ã³åºããéâ¦
http://projecteuler.net/index.php?section=problems&id=157 150çªãããã®åé¡ã«ãã¦ã¯ç°¡åã import Control.Monad import Number import Data.List divisor100 n = [2^x*5^y | x <-[0..2*n], y <- [0..2*n]] primitiveSolutions n = filter (uncurry (<=â¦
http://pooh.gr.jp/item-229.html#top
http://projecteuler.net/index.php?section=problems&id=156 import Data.Char import Data.List count :: Int -> [Int] -> Integer count d = genericLength.filter(==d) listToInt :: [Int] -> Integer listToInt = foldl' add 0 where add a b = a*10+toâ¦
;;; ãã©ã³ãã®è¨å® (w32-add-font "Osaka 16" '*1 *2 *3 *4 *5 *1:spec ((:char-spec ascii :height any) strict (w32-logfont "Osakaâçå¹ " 0 -16 400 0 nil nil nil 0 1 3 0 *2::char-spec ascii :height any :weight bold) strict (w32-logfont "Osakaââ¦
http://projecteuler.net/index.php?section=problems&id=155 ã¡ã¢ãªä¸è¶³ã«ãªã£ããããã ç´ ç´ãªã¢ã«ã´ãªãºã ã import Data.Array import qualified Data.Set as S n = 18 main = print.sum.map S.size.elems$ caps caps = listArray (1,n) $ (S.singletonâ¦
http://projecteuler.net/index.php?section=problems&id=154 3é ä¿æ°ã®ç´æ°ã«ã¤ãã¦ã haskellã§ã®å®è£ ã import Control.Monad import Data.Array.Unboxed import Data.List n = 2*10^4 d = 10 main = print p154 factor p x | mod x p == 0 = succ.factorâ¦
4n+1åã®ç´ æ°ãå¹³æ¹æ°ã®åã«å解ããã e.g. 5 = 1+4=1^2+4^2 1249 = 15^2+32^2 17669 = 70^2+113^2 225221 = 410^2+239^2 import Number import Data.List pRoot p = g.foldl1' f $ [1..div (p-1) 2] where f a b = mod (a*b) p g x = min x $ p-x sqSum p â¦
http://projecteuler.net/index.php?section=problems&id=153ã¨ããããæ¸ããããéãåããªããï¼10^8ã£ã¦ããªã大ããæ°ããããã§ãããï¼ import Number import Data.List -- ãã¼ã¤ããªå®è£ divisors n = [(a,b)| a <- [1..n], b <- [0..n-1], mod (n*â¦
http://projecteuler.net/index.php?section=problems&id=152大ããªç´ å æ°ãæã¤æ°ããèãã¦ãããæ®ããï¼ï¼ï¼ã«ãªã£ããå ¨æ¢ç´¢ãéå§ã import Number (primes, isPrime, merge) import Data.List (groupBy, sortBy) import Data.Ratio (Ratio, denominatâ¦
cygwin.bat @echo off E: chdir E:\cygwin\bin REM bash --login -i REM zsh --login -i rxvt -e zsh --login -i ~/.Xdefaults Rxvt.geometry: 120x35+0+0 Rxvt.font: Terminal-18 Rxvt.mfont: Terminal-18-jisx0208 Rxvt.multichar_encoding: sjis Rxvt.visâ¦
ã¯ã©ã¹ãã¹ã®æå®ã³ã³ãã¤ã«æ javac -classpath /usr/ilog/cplex112/lib/cplex.jar Test.java javac -classpath ".;c:\\ILOG\\CPLEX112\\lib\\cplex.jar" LPex1.java å®è¡æ java -classpath ".:/usr/ilog/cplex112/lib/cplex.jar" -Djava.library.path=/usâ¦
ãã¹ã«ã«ã®3è§å½¢ã¯æ¬¡ã®ã³ã¼ãã§çæã§ããã pascal = iterate next [1] where next xs = zipWith (+) (0:xs) (xs++[0]) showPascal n = mapM_ print.take n$pascal *Main> showPascal 10ã¨ããã°ã次ã®ãããªãã¹ã«ã«ã®ä¸è§å½¢ãå¾ãããã [1] [1,1] [1,2,1â¦
http://projecteuler.net/index.php?section=problems&id=151 ã¯ããã¯å¤æ°åãã¹ã§ã«ã¼ãã«é¥ã£ã¦ããã main = print.expect$(1,1,1,1) expect (0,0,0,1) = 0 expect (0,0,1,0) = 1 expect (0,1,0,0) = expect(0,0,1,1) + 1 expect (1,0,0,0) = expect(0,1â¦
http://projecteuler.net/index.php?section=problems&id=150 ä¸è§å½¢ã®é«ããnã¨ããã¨O(n^3)ã®ã¢ã«ã´ãªãºã ã å¥ã®O(n^3)ã®ã¢ã«ã´ãªãºã ãå®è£ ãããããã¡ããã20åãããéãã ãã¡ãã®ã»ãããé åè¨ç®éã«é¢ãã¦æªãã®ã ã(rãå¿ è¦)ããªããéãã imâ¦
åè«ãå ¨ç¶ããã¾ãã¼ã ç®æ¬¡ã¨ãæ¸ããã£ã¦ãããããã©ã æ£ç´æ¸ããã¨ããã¾ãªãã®ããã ãã¼ãå°ã£ãã å ¨ç¶ææåºã¦ãªããã ãã¼ãå°ã£ããï¼°ï¼£ã®ãªãã®å°äººããããã°ã£ã¦ããã¼
http://projecteuler.net/index.php?section=problems&id=149 æ大é¨ååååé¡ãç¹°ãè¿ã解ãã¦ããã ãã import Data.List import Data.Array.IArray m = 2*10^3 sArray = sa :: Array Integer Integer where sa = listArray (1,m^2). map s' $ [1..m^2] â¦
èªå® ã®PCããç°é³ããã件ã«ã¤ãã¦ã ãã¨ãã¨Windows 2000ãå ¥ã£ã¦ãPCã ããããããããã«å¯¿å½ãï¼
http://projecteuler.net/index.php?section=problems&id=147 é·æ¹å½¢ã®æ°ãæ°ããç°¡åãªãä»äºã ãããã¨ã¯åç´ã ããçµæ§é£ããã ã¨ããããé·æ¹å½¢ã®å¤ããã«æ ¼åç¹ã§èããã ãã¨ã¯é åå ã«ä½ç¹ããããæ°ããã°ããã ãã å ´åãããããã©ãããã ãâ¦
http://projecteuler.net/index.php?section=problems&id=148 観å¯ãããè¦åæ§ãã¿ã¤ãï¼è¨¼æã¯ãã¦ããªãããç´å¾ã§ããè¦åæ§ãªã®ã§ããã¨ããï¼ããããå©ç¨ã è¦ããã«7é²æ°å±éãã¦ããã«ããã«ãã£ã¨ããã¨çããåºã¦ããã import Data.List toSeptaâ¦
http://projecteuler.net/index.php?section=problems&id=146 import Number import Data.List import Control.Monad step = [1,3,7,9,13,27] indivisible p n = and [mod (n*n+s) p /= 0 | s <-step] residue u p = [n | n <-[0..min u (p-1)], indivisibleâ¦
Project Euler ã¤ãã«150å解ãã¾ãããLevel4ã«ãªãã¾ããã