P21730 [GeeksforGeeks] Dr zoras algorithm5401
普及-
题目描述

Dr. Zora built an algorithm to set the destructive or danger year, his algorithm contains a pattern of years which were set by Hydra for attacks. As the Avengers needs to be ready mentally as well as physically. Agent Natalia Romanoff is assigned the task to detect the pattern of the selection of destruction year, and help Avengers. Agent Romanoff observes from the past details that, year ........,1824, 1842, 1848, 1860........, 1912, 1918, ......2012 were Destructive Years. Now observing the pattern Agent Romanoff needs to design an algorithm to determine future Destructive Years. Help her!
Example 1:
Input: Year = 1848
Output: "Destructive Year"
Explanation: According to agent Romanoff
Year 1848 is Destructive.
Example 2:
Input: Year = 1973
Output: "Non-Destructive Year"
Explanation: According to agent Romanoff
Year 1973 is Non-Destructive.
Your Task:
You dont need to read input or print anything. Complete the function isDestructive() which takes year as input parameter and returns that its Destructive or Non-Destructive.
Expected Time Complexity: O(logn)
Expected Auxiliary Space: O(1)
Constraints:
200<= year <=9999

输入格式

见题面

输出格式

见题面

样例输入
Year = 1848
样例输出
"Destructive Year"