Friday, January 4

做一道小学数学题

“用1到8这八个自然数组成两个四位数(不可重复使用),其中一个四位数是另一个四位数的4倍,请问这两个四位数分别是……” 这确实是一道小学四年级的数学题,你知道怎么做吗?前天,重庆大学大三学生赵旭婷也很犯难,因为这正是弟弟的一道假期作业题。无奈之下,她只好求助同学,结果一算就是半个小时……
让我们用小学数学来解决它!

首先看个位数 :如果第一个数的个位数是1,那么第二个数的个位数必然是4,才可能成为第一个数的4倍。如此类推,我们可以得出7个可能的组合:
xxx1 - xxx4
xxx2 - xxx8
xxx3 - xxx2
xxx4 - xxx6
xxx6 - xxx4
xxx7 - xxx8
xxx8 - xxx2

先看第一个组合:xxx1 - xxx4
第一个数的千位数不能为1(已经被使用了),所以只能为2,才能让第二个数的千位数是在1-8之间,可是第一个数的百位数最小也只能是3,那么第二个数的千位数连8都不够了。因此,这个组合不能实现。

第二个组合: xxx2 - xxx8
根据上面的讨论,第一个数的千位数只能为1 (2已经被使用)。
看十位数,只能有这两个组合:
1x42 - xx68
1x62 - xx48
因为1x32会产生 xx28,而2重复;
1x52会产生xx08,0是非法字符;
1x72 会产生xx88,8重复。
现在看1x42-5x68组合:
1342*4=5368, 3重复,不可用。
1542*4= 6168
1642*4=6568
1742*4=6968,不可用。

第三个组合:xxx3 - xxx2
第一个数的千位数必然为1。百位数大于或等于4,因此第二个数的千位数可以是6或7。
看十位数,只能有:
1x43 - xx72
1x63 - xx52
现在看1x43 - xx72组合:
1543*4=6128, 1重复
1643*4=6572
1843*4=7372
都不可以。
现在看1x63 - xx52组合。第二个数的千位数只能是7,那么第一个数的百位数只能是8才能凑够:
1863*4=7452。 成功!


可以继续用下面4个组合把所有可能的配对都找出来。

Labels:

Thursday, January 3

Some CSS styles that I can use

I'm reading a book of "PLUG-In CSS" and I found some styles that I can use:

1, Encapsulation:
P:before {content:'\201c';"}
P:after {content:'\201d';"}

2,Symbols:
add a checkmark for class CheckmarkButton:
.CheckmarkButton:before{content:'\2713';}
add a crossmark for all button that has value="Cancel" property:
form input [value="Cancel"]:before{content:'\2715';}

3, Progress Bar, showing green for finished progress, red for unfinished:
< div class='progressbar' >< div style='width:65%' / > < /div >
.progressbar {
  position:relative;
  width:120px;
  height:15px;
  border-width: 1px;
  border-style:solid;
  border-color:Black;
  background-color:Red;
  }
.progressbar div{
  position:absolute;
  height:15px;
  top:0px;
  left:0px;
  background-color:Green;
}


4, Odd and Even Background Colors
< table class="striptable" >
.striptable tr:nth-child(odd) {background:Grey;}
This "nth-child()" is an interesting selector. You can use "nth-child(3n+2)" to select 2nd, 5th, 8th, 11th, etc elements.
This selector is not working in IE8 and below.

The pesudo-classes are new to me. Here is a list from W3cSchools:

All CSS Pseudo Classes/Elements

Selector Example Example description
:link a:link Selects all unvisited links
:visited a:visited Selects all visited links
:active a:active Selects the active link
:hover a:hover Selects links on mouse over
:focus input:focus Selects the input element which has focus
:first-letter p:first-letter Selects the first letter of every element
:first-line p:first-line Selects the first line of every element
:first-child p:first-child Selects every elements that is the first child of its parent
:before p:before Insert content before every element
:after p:after Insert content after every element
:lang(language) p:lang(it) Selects every element with a lang attribute value starting with "it"

I will use these newly learnt technique into this blog.