Problem
Tags : GCD , LCM .
Idea : This is a simple problem . Just need to know gcd and lcm evaluation .
Given a string consisting Y and N .
First , you have to calculate the lcm of the position index of Y in the string .
If the lcm is divisible by any position index of N in the string, print -1 else print the lcm .
If there is no Y in the string , lcm is 1 .
My Solution
No comments:
Post a Comment