2010-01-01ãã1å¹´éã®è¨äºä¸è¦§
Problem 7 é åãã©ãã使ãã«ãã¦ãã大ããªé åã¯ä½¿ããªããã¨ããããã¾ããã ããã§ã¨ã©ãã¹ããã¹ã®ãµãããå°ããªç¯å²ã§è¡ãããããç¹°ãè¿ãããã«ãã¾ãããã以åã«å¿ è¦ãªç¯å²ã®ç´ æ°ã¯ããã¾ãã¨ã©ãã¹ããã¹ã®ãµãããã£ã¦æ±ãã¦ããã¾ããããã§â¦
試è¡é¯èª¤ãã¦ããã¨ãç°å¢å¤æ°ãå¤ãã¨é ããªããã¨ããããã¾ããã ã¾ããæå®ããæ°ã ãé åãã©ãã®å¤æ°ãçæãããã®ãã¨ã«åç´ãªåãåãå¦çã«ãããæéãè¨æ¸¬ãã¾ããã å¤æ°ã®æ° å¦çæé 10 11.38s 100 12.03s 1000 15.95s 3000 26.00s 10000 61â¦
Problem 7 ãã®åé¡ã¯ã10001çªç®ã®ç´ æ°ãæ±ããã¨ããã®ããã½ã§ããã ããã¨ã©ãã¹ããã¹ã®ãµãããããã¤ã¾ã§ããã°ããã®ããããã¾ãããããã¯ææãããã¾ããN = 10001ã¨ãã¦ãN log2 Nã¾ã§ãµããã«ããããã¨ã«ãã¾ããã¡ãã£ã¨å¤§ããã§ãããããâ¦
Problem 7 é åï¼ ç´ æ°ãæ±ããã¨ããã°ããµã¤ãã¯ã¨ã©ãã¹ããã¹ã®ãµããã§ãããããã«ã¯é åã使ããªããã°ãªãã¾ãããããããããããã¡ã¤ã«ã«é åã¯ããã¾ãããã§ã¯ã©ãããã°ããã§ãããããããªã®ã¯ã©ãã§ããããã @echo off for /L %%i in (1,â¦
http://projecteuler.net/index.php?section=problems&id=316 ãã¡ããã§ãããã©ãé ãã ãã¾ãã¡ã¢åã§ããªãã
http://projecteuler.net/index.php?section=problems&id=316 é常ã«å°éã«ã³ã¼ããæ¸ãããç°¡åã«27280188ãåºããã§ãé ãã ã¡ã¢åãã¦200ç§ã«ãªã£ãããçãããã£ã¦ããªããããã
http://projecteuler.net/index.php?section=problems&id=316 æ¼ããããg(535)ãè¨ç®ãã¦ãããããã£ããã«1008ã«ãªãããã«ãªããããããªãã¸ã§ã®ã³ã°ã«åºããã¦èãã¦ãããããã£ã±ããªããªãã帰ã£ã¦ç似乱æ°ã使ã£ã¦è¨ç®ãã¦ã¿ãã¨ããããªæãã®æ°â¦
Problem 7ç´ æ°ã®å¤å®ãå帰ã«ããã¨ãããã«é ãã®ã§ã«ã¼ãã«ãã¾ãã :is_prime setlocal set /a n = %1 set /a k = 2 :loop_is_prime set /a k_sq = %k% * %k% if %k_sq% GTR %n% exit /b 1 set /a r = %n% %% %k% if %r% == 0 exit /b 0 set /a k += 1 goâ¦
http://projecteuler.net/index.php?section=problems&id=316 ããã¯ãå¤ãé ãã諦ããã»ããããããªï¼ 風åå ¥ã£ã¦èãããã ãã ãããã£ã¦ãããã§ããããããããã«è§£ããã¨ã¯æããªãã®ã§ãææ¥ãã£ããèãããã§ããã°ã¸ã§ã®ã³ã°ããªããèããããâ¦
Problem 7é£ããåé¡ãæ¥ã¾ããã ä¸ã¤ãã¤ç´ æ°ãã©ãããã§ãã¯ãã¦ããã°ã¨ã¦ãéã«åããªãã§ãããã
æéè¨æ¸¬ã§ããããã«ãªã£ãã®ã§ããã³ããã¼ã¯ãã¦ã¿ã¾ãããã1ã1000ã®åã4ã¤ã®æ¹æ³ã§æ±ãã¾ãããããããforãgotoãfor+callã§åãããã®ãããã¦å帰ã使ã£ããã®ã§ãã 500500 for : .07s 500500 goto : 1.57s 500500 for+call : 1.38s 500500 recuâ¦
æéè¨æ¸¬ %TIME%ã¨ããç¹æ®ãªç°å¢å¤æ°ããããããã«ã¯ç¾å¨ã®æå»ãæ ¼ç´ããã¦ãã¾ãã echo %TIME% 12:09:22.90ãªã®ã§ããã®æååãåºåã£ã¦æã»åã»ç§ã«ããã°ããã§ãã ãããããã®åã次ã®ããã«åãã¨ã set t=%TIME% set /a m = %t:~3,2% ç¡å¹ãªæ°â¦
Problem 6 é«éé¢æ°ï¼ Pythonã ã¨ãããªæãã«æ¸ãã¾ãã from itertools import imap N = 100 s = sum(xrange(1, N + 1)) s2 = sum(imap(lambda n: n * n, xrange(1, N + 1))) print s * s - s2 sumã¯reduceã使ãã°ã N = 100 s = reduce(lambda x, y: x +â¦
http://projecteuler.net/index.php?section=problems&id=315 1ã¹ãããã§100æªæºã«ãªãã®ã§ã100æªæºãã¡ã¢åãããããã§ã1ååããªããã¨ã©ãã¹ããã¹ã®ãµãããé ãããããéããã¦41ç§ã
http://projecteuler.net/index.php?section=problems&id=315 ãã¶ãããªãã®å¤å²ããªãåé¡ã ã¨æããã 解ãããå®è¡æé2åã 20çãã5åé ãã£ãããã£ã±é ãéã£ã¦ããã
Problem 6çããåºãã ããªãåã®å ¬å¼ã§çµããã§ããã @echo off set /a N = 100 set /a s = %N% * (%N% + 1) / 2 set /a s2 = %N% * (%N% + 1) * (%N% * 2 + 1) / 6 set /a result = %s% * %s% - %s2% echo %result% forã§åããªãã @echo off set /a N =â¦
Problem 5æå°å ¬åæ°ãæ±ããã ãã§ãã æå°å ¬åæ°ã¯æå¤§å ¬ç´æ°ããããã°æ±ã¾ãã¾ããæå¤§å ¬ç´æ°ã¯å帰ã§ç°¡åã«æ±ã¾ãã¾ãã
Problem 4ãã®æã®åé¡ã¯ãåææ°ã§ããããå¤å®ããã®ã§ã¯ãªããåææ°ãçæããã®ãå®çªã§ããåææ°ãçæããã«ã¯ãä¾ãã°987ãªãå転ãã¦789ã«ãã¦çµåãã¦987789ã¨ãã¾ããã¾ããå転ã§ãã :reverse setlocal if %1 == 0 exit /b %2 set /a d = %1 %â¦
Problem 4ã¾ããããèªç¶æ°ã3æ¡ã®èªç¶æ°å士ã®ç©ã«ãªã£ã¦ãããã©ããã調ã¹ãã³ã¼ããæ¸ãã¾ãããã999ããéé ã«å²ã£ã¦ãã£ã¦ãå²ãåãããç©ã«ãªã£ã¦ãã¾ããå²ãç®ã®çµæãèªå以ä¸ã«ãªã£ããç©ããªããã¨ã«ãªãã¾ãã :is_product setlocal set /a dâ¦
Problem 3é·æ´æ°ã®æãç®ã¯4æ¡ãã¤ã«ãããã°ç°¡åã§ãããããå²ãç®ã¯é£ããã§ããããã§ã¯ææããã¦ãã¾ããé¤æ°ã¯32ãããã®æ´æ°ã使ã£ã¦ã被é¤æ°ã4æ¡ã«åãã¦ãã¾ããããããé¤æ°ã¯æ大6æ¡ã§ãä½ããæ大6æ¡ã«ãªãã®ã§1ä¸åããã10æ¡ã«ãªã£ã¦ãªã¼ãâ¦
http://projecteuler.net/index.php?section=problems&id=314 åé¡æãé·ããæå³ãç解ããã®ã«8åãä»ã¾ã§ã«ãªãã¿ã¤ãã®åé¡ã ãã¡ãã£ã¨è²·ãç©ã«ã§ããã¦èããããªã 25åãããè²·ãç©è¡ã£ã¦ãããã©ããã¾ãæãã¤ããªãã£ãã ãã£ã¨125ãåºãããã®â¦
Problem 3æ©ããé£åããã£ã¦ãã¾ãããããã¯12æ¡ã§32ãããã§è¡¨ããªãã®ã§é£ããã§ãããã®åé¡ã解ããã°ããã¨ãããã®ã§ãããã¾ãããããç¨åº¦ã¯ä¸è¬åãããã¨ããã§ããããã§ã¯ã12æ¡ã¾ã§ã®å ´åã«ãªãã¹ã解ããããã«ãã¾ãã ã¾ãã¯Pythonã§æ¸ãâ¦
è¤åä»£å ¥æ¼ç®å ãããªæãã®æ¼ç®åã§ãã set /a n += 1 nã¨ããå¤æ°ã«1ãå ãã¦ãã¾ãããããã @echo off set /a n = 1 setlocal set /a n += 1 echo %n% endlocal echo %n% 2 1ãã£ã±ãã
Problem 2ã¯ç°¡åã§ãããã£ããããæ°åã¯å帰ã§çæã§ãã¾ãã @echo off set /a N = 4000000 call :Fibonacci 0 1 echo %ERRORLEVEL% exit /b 0 :Fibonacci setlocal set /a f = %1 + %2 if %f% GTR %N% exit /b 0 call :Fibonacci %2 %f% set /a r = %f% â¦
http://twitter.com/cddddr/status/12632522261266432ãã®ãããã«ã¤ãã¦ã¯åããä½åº¦ãèãã¦ãã¦ãä¾ãã°Project Euler 110ï¼1ï¼ã«ãæ¸ãã¦ãããããªããªãé£ããã ããããã¡ã¤ã«ã®ã»ãã¯Problem 11ã¾ã§æ¸ããã®ã§ãã¾ãèãã¦ã¿ããã¨æãããã£ã¨ããâ¦
å帰 å¤æ°ããã¼ã«ã«ã§ãªãã£ãããgotoã使ããã¦ããã®ãæ°ã«å ¥ããªãå ´åã¯ããã£ã±ãå帰ã§ãããããããããéä¹ã®ä¾ãè¦ã¦ã¿ã¾ãããã @echo off call :factorial %1 echo %ERRORLEVEL% exit /b 0 :factorial setlocal if %1 == 0 exit /b 1 set /a â¦
å³æå¤æ°å±é forã¨ifã使ããããã«ãªã£ãã®ã§ãProblem 1ãé¡æã©ããã«æ¸ããã¨ãã§ãã¾ãããã ããããããã¡ã¤ã«ã«ã¯andãorã¯ãªãã®ã§ãããã¯ifã2ã¤ä½¿ããã¨ã«ãªãã¾ãã @echo off set /a N = 1000 set /a M = %N% - 1 set /a s = 0 for /L %%i inâ¦
forã³ãã³ã ãã®åé¡ã¯åã®å ¬å¼ã使ã£ã¦ãããã®ã§ããã使ããªãã®ããµã¤ãã®è§£ãæ¹ã®ããã§ããããããforã³ãã³ããããã®ã§ãããã§åããã¨ãã§ãã¾ããforã«ã¯ãããããã¿ã¼ã³ãããã¾ããã/Lãæå®ããã¨å¤æ°ãå¤åããããã¨ãã§ãã¾ãã @echo â¦
setlocalã³ãã³ã setlocalã¯endlocalã¾ãã¯exitãå¼ã°ããã¾ã§æå¹ã§ãã @echo off set /a n = 1 setlocal set /a n = 2 setlocal set /a n = 3 echo %n% endlocal echo %n% endlocal echo %n% 3 2 1æ°ãã¤ããªããã°ãããªãã®ã¯ãsetlocalã¯é¢æ°ãå¼ãã â¦
http://projecteuler.net/index.php?section=problems&id=313 ãã£ã¨åºæ¥ãã2ç§ããªãã ããããç°¡åãªåé¡ã®ã¯ããªã®ã«ã