Professional Documents
Culture Documents
(Five Jack) SE Online Test
(Five Jack) SE Online Test
(Five Jack) SE Online Test
In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers.
For any positive integer n, define d(n) to be n plus the sum of the digits of n.
Some numbers have more than one generator: for example, 101 has two generators, 91 and 100.
There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.
- Write a program to sum of all self-numbers which are bigger than 0 and smaller than 5000.
Question 2.
There is a room with n rows and n columns, and there are gunmen in the room.
A gunman can see vertical or horizontal way, and cannot see over the wall or diagonal.
If a gunman see another gunman, they will shoot each other and only one man will survive.
■: Wall
□: Empty space
♂: Gunman
■■■□
□□□□
□■□□
■■■□
■■■□
□□□♂
♂■♂□
■■■□
However, we cannot place gunmen like below, because they are in the same line horizontally, one man
will die.
■■■□
□♂□♂
□■□□
■■■□
We can place maximum 4 gunmen in this room, and there are 2 ways to achieve this.
■■■♂
□♂□□
♂■♂□
■■■□
■■■□
□♂□□
♂■♂□
■■■♂
□□□□□■□□
■□■□□■□■
□□□□□□□□
□□□■□□□□
□□□□□■□■
□■□□□□□□
□□□□■□■□