You are not logged in. Please login at www.codechef.com to post your questions!

×

Help in CF Problem Round 489 Prob B

I don't know why my solution is giving WA. Though it is not the approach given in the editorials still I can't figure out where my solution is wrong.

Question Link : http://codeforces.com/contest/992/problem/B

My Solution : http://codeforces.com/contest/992/submission/39371128

asked 19 Jun '18, 22:23

jagreetdg's gravatar image

3★jagreetdg
2189
accept rate: 9%


Your assumption that if xy is a perfect square then root of it will be a valid pair seems wrong. In the 15th test case where you are getting wrong answer (r,r) is not a valid pair. So i modified that statement to
if(r
r==xy && __gcd(r,r)==x) ans--;
The output comes 16 now. Try to resumbit it now

link

answered 19 Jun '18, 23:11

vbt_95's gravatar image

4★vbt_95
4406
accept rate: 27%

__gcd(r,r) will be r which may or may not be equal to x but outside the loop you are checking r*r==xy then subtracting 1 from ans but (r,r) may not have been taken into account.

link

answered 19 Jun '18, 23:15

anno's gravatar image

4★anno
266211
accept rate: 12%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×655
×2
×1

question asked: 19 Jun '18, 22:23

question was seen: 123 times

last updated: 19 Jun '18, 23:15