You are viewing a single comment's thread. Return to all comments →
Assume that the shark has gone till he has reached the square number n and there, his strength has became 0 .
We know that n have to be divisible by 2 . The number of squares that are divisible by 2 and <= n is floor ( n/2 ) .
The number of squares divisible by 42 is floor ( n / 42 ) .
Here we want the number of squares divisible by 2 and not divisible by 42. Though we have floor (n/2) - floor(n/42) = s .
To solve this equation, you can write it in the form without floor functions (( n/2 + n/42 = s )) .
Then solve this equation. Let the answer to be x. First take the integer part of x.
Then set x as x-10. At last, run a loop from 0 to 20 and in each iteration, increment x.
After incrementing, check if x%2 ==0 and floor(x/2)-floor(x/42) == s .
The first x that satisfies the constraints is the answer.
Sorry for my bad English.
Seems like cookies are disabled on this browser, please enable them to open this website
Wet Shark and 42
You are viewing a single comment's thread. Return to all comments →
Assume that the shark has gone till he has reached the square number n and there, his strength has became 0 .
We know that n have to be divisible by 2 . The number of squares that are divisible by 2 and <= n is floor ( n/2 ) .
The number of squares divisible by 42 is floor ( n / 42 ) .
Here we want the number of squares divisible by 2 and not divisible by 42. Though we have floor (n/2) - floor(n/42) = s .
To solve this equation, you can write it in the form without floor functions (( n/2 + n/42 = s )) .
Then solve this equation. Let the answer to be x. First take the integer part of x.
Then set x as x-10. At last, run a loop from 0 to 20 and in each iteration, increment x.
After incrementing, check if x%2 ==0 and floor(x/2)-floor(x/42) == s .
The first x that satisfies the constraints is the answer.
Sorry for my bad English.