levi.ackerman1732's blog

By levi.ackerman1732, history, 5 years ago, In English

230B - T-primes

Hello all,

I am a bit new to this online coding platform hence I am sorry if I am asking anything that is fairly obvious. Getting to the solution of the question: If a number has to be T-Prime, it has to be a perfect square of a prime number.

My algo: 1)check if the number is a perfect square. 2)If it is a perfect square check if the square root is a prime number.

Problem I am facing: My code is working fine for many test cases, but failing at test case 16 with an error(wrong answer 28561st lines differ — expected: 'NO', found: 'YES') The input for 28561th line is 28561(169*169). In my system it is showing "NO" (not a t prime) which is correct.

I don't know where it went wrong. Any help is appreciated. Thank you.

My submission

  • Vote: I like it
  • +29
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
Rev. 2   Vote: I like it +26 Vote: I do not like it

I accept your code!

your problem was pow() function because its returns double and double has error! you can compare your code with mine to see the problem:)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +19 Vote: I do not like it

    Thank you very much. The i*i<=n, that is a new perspective for me. Once again Thank you.