[BaekJun, C++] 1018: Movie Director
https://www.acmicpc.net/problem/1436
문제
It is said that 666 represents the end of the world. Therefore, many blockbuster movies often use titles containing the number 666. Director Sean is in charge of a movie series called "The End of the World." When George Lucas created Star Wars, he named the movies as Star Wars 1, Star Wars 2, Star Wars 3, Star Wars 4, Star Wars 5, and Star Wars 6, and similarly, Peter Jackson named his movies as The Lord of the Rings 1, The Lord of the Rings 2, The Lord of the Rings 3 when making "The Lord of the Rings." However, Sean decided to make his movie titles a bit different to demonstrate that he surpasses George Lucas and Peter Jackson.
The term "end of the world number" refers to a number with at least three consecutive 6s. The smallest end of the world number is 666, and the next larger numbers are 1666, 2666, 3666, and so on. Therefore, Sean's first movie's title will be "The End of the World 666," and the second movie's title will be "The End of the World 1666," and so on. In general, the title of the Nth movie made by Sean is "The End of the World" followed by the Nth smallest end of the world number.
Input
the first line is N, N is an integer less than or equal to 10,000
Output
It prints the Nth movie title
Code
It was difficult to find if there are three consecutive 6's while it's easy to find just one
but just check if the nubmer mod 1000 is 666 and keep on dividing by 10
so it's a Brute Force Problem
Time Complexity
O(n^2)
Space Complexity
O(1)
Comments
Post a Comment