This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sum = 2; | |
for ($i = 3; $i <= 10000; $i++) { | |
$k = 1; | |
for ($j = 2; $j < $i; $j++) { | |
if ($i % $j == 0) { | |
$k = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MAX_NUM', 1000000); | |
$all = array_fill(0, MAX_NUM, 0); | |
$i = 2; | |
if ($all[$i] == 0) { | |
echo $i . "\n"; //测试性能时去掉这行。输出会占据大部分时间。 | |
for ($j = $i; $j < MAX_NUM; $j+=$i) { | |
$all[$j] = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sum = 2; | |
for ($i = 3; $i < 10000; $i+=2) { | |
$flag = TRUE; | |
for ($j = 2; $j <= sqrt($i); $j++) { | |
if ($i % $j == 0) { | |
$flag = FALSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Design done by Arthur Steiner (c), the rest by Anne van Kesteren (c) */ | |
@font-face { font-family:anneisawesome; src:url(/fonts/big-noodle-titling) } | |
html { margin:20px 30px; font:1em/1.5 Verdana, sans-serif; background:#46016a } | |
body { position:relative; margin:0 0 0 160px; padding:0 1em; border-left:10px solid #7e7a4c; min-width:200px; background:#c2c152 } | |
h1 { position:absolute; top:5px; left:-155px; margin:0; height:107px; width:282px; z-index:1; content:url(/img/logo) "Weblog 4.2"; font:2.6em/0.4 anneisawesome, Impact, sans-serif; text-indent:-4px } | |
p#tagline { margin:0; padding-top:5em; font-size:1.2em } | |
form#search { position:absolute; top:10px; right:20px; z-index:1 } | |
form#search input[type=search] { border:thin solid #000; vertical-align:top } | |
form#search input[type=search]:focus { outline:thick solid #000 } | |
form#search input[type=submit] { margin:2px 0 0; padding:0; border:none; float:right; display:block; content:url(/img/find); width:30px; cursor:pointer } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function odd($var) { | |
return($var & 1); | |
} | |
function even($var) { | |
return(!($var & 1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function window.onload() | |
{ | |
var olink=document.links; | |
for(var i=0; i<olink.length; i++){ | |
olink[i].onmouseover=function(){window.status='';return true;} | |
olink[i].onfocus=function(){window.status='';return true;} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){readConvertLinksToFootnotes=false;readStyle='style-novel';readSize='size-medium';readMargin='margin-wide';_readability_script=document.createElement('script');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.documentElement.appendChild(_readability_script);_readability_css=document.createElement('link');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.documentElement.appendChild(_readability_css);_readability_print_css=document.createElement('link');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_cs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sfHover = function() { | |
var sfEl = document.getElementById("menu"); | |
if(sfEl){ | |
var sfEls = document.getElementById("menu").getElementsByTagName("LI"); | |
for (var i=0; i<sfEls.length; i++) { | |
sfEls[i].onmouseover=function() { | |
this.className+=" sfhover"; | |
} | |
sfEls[i].onmouseout=function() { | |
this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* 八皇后问题是一个非常有趣的问题,是由德国大数学家高斯首先提出来的。 | |
* 要求在国际象棋的棋盘上放置八个皇后,使她们不能互相攻击。 | |
* 即任何两个皇后不能处在同一行、同一列、同一条斜线上。 | |
* | |
* 问有多少种不同的摆法?并找出所有的摆法。 | |
* | |
* 问题分析: | |
* (1) 满足上述条件的八个皇后,必然是每行一个,每列一个。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
u'''cdays-3-exercise-3.py | |
@note: 使用全局变量和函式的递归调用 | |
''' | |
global col # 竖直线(列线),用于记录列线冲突状态 | |
global row # 行号,本代码是逐行放置的,这里的row是可以当做do_queen函数的参数的。 | |
global pos_diag # 右对角线,用于记录右对角线冲突,拿笔画画就知道有15条左对角线了 | |
global nag_diag # 左对角线,用于记录左对角线冲突状态,同样也有15条右对角线 |
OlderNewer