读万卷书,行万里路

2019年9月25日星期三

It all adds up, too

没有评论 字体大小:[小] [中] [大]
注:POTW,就是Problem of the Week的缩写,意思是每周问题。这是加拿大滑铁卢大学组织的活动,每周将一道题目提供给各地的中学生。学生们每周将题解出来后,可以将答案发给自己的学校,与自己学校里的同学互相比拼,并在学期末看看谁做对得更多。

    在这道题之前,我一直以为每周的这些题目都是数学题。但是在看了这道题后,感觉用数学的列举法根本是不可能找到答案的啊!即使找到了,也没有什么意义。再一看POTW网站的标题,顿时恍然大悟,原来写的是“The CENTRE for EDUCATION in MATHEMATICS and COMPUTING”。每周的挑战力加入编程的元素,顿时让我浑身充满能量啊!有兴趣的同学可以自己来看看:https://www.cemc.uwaterloo.ca/resources/potw.php

This code is to find out the 3-digit numbers that have their digits add up to 9. The problem was originated from the "Problem of the week" from the university of Waterloo. The original question is stated here: https://www.cemc.uwaterloo.ca/resources/potw/2019-20/English/POTWD-19-NA-02-P.pdf

The digit positive integer is the sum of all of its digits. For example, the digit sum of the integer 1234 is 10, since 1 + 2+ 3 + 4 = 10. Find all three-digit positive integers whose digit sum is exactly 9.

This is the answer that I got, it can also be found out through running the code by pressing the green button:

108
117
126
135
144
153
162

Well, but there is another problem that I do not know how to solve. The problem can be found here: https://www.cemc.uwaterloo.ca/resources/potw/2019-20/English/POTWE-19-AE-02-P.pdf. If you find out the answer, please leave a comment!

没有评论 :

发表评论