Sangar Number

My classmate, Yasya', gave me this wonderful problem when we were high school students. The problem was about Sangar Number. The word sangar itself is the Javanese language of wonderful .

Let N N is a Sangar Number if it satisfies the following conditions :

  • There are integers A , B , C A, B, C such that A C × B C = N C \overline{AC} \times \overline{BC} = \overline{NC}
  • 1 N , A , B , C < 1 0 9 1 \leq N, A, B, C < 10^{9}
  • N , A , B , C N, A, B, C don't have leading zero

As an example, 309 309 is a Sangar Number shown in the picture above.

Yasya' also gave me a list of 999 999 integers here . He challenged me to find out how many Sangar Numbers in there.

Can you help me to solve this problem?

This problem is taken from TOKI Open Contest January 2013 (Problemsetter : Me and Yasya')


The answer is 630.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Here, I just want to give some clues (not the complete solution) so you can still get the enjoyment of problem solving if you haven't got the answer yet : 630 \boxed{630} :)

  • Let D ( x ) D(x) be the function returning the number of digits of integer x x .
  • The first step is to find all possible values of C C . There are 17 17 possible values of C C which can be achieved with bruteforce with the help of function D ( x ) D(x) and modulo.
  • Because there only 17 17 possible values of C C , we can brute them all.
  • Next, how about A A and B B ? We can brute only one of them! Let's say we brute the value of A A . Because we have known N , A , C N, A, C , we can find the value of B B (of course you have to check whether B B is an integer or not).
  • The value of A A can be up to 1 0 9 10^9 (which is still too slow if we bruteforce until this number). Luckily, there is a smaller upperbound to brute the value of A A . Hint : Let A B A \leq B .
  • Again, the function D ( x ) D(x) plays a role to check if N N is a Sangar Number or not.

With these algorithm, I can get the answer in ~ 20 20 seconds.

Alright then, happy solving guys! :D

Sangar :D

pebrudal zanu - 7 years, 4 months ago

I'm a Javanese and I thought "sangar" means frightening :|

Mu'amar Musa Nurwigantara - 7 years, 1 month ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...