juice04's blog

By juice04, history, 2 months ago, In English

I was trying to solve this question using smallest prime factor sieve. but i'm encountering a runtime error on my submission. could someone pls take a look into it and point the error out (FYI, it ran perfectly on my system IDE). tyvm in advance.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

You created a vector of size 10^9 . That is not possible in c++

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    alright thank you, could you please suggest an alternative if you can?

    • »
      »
      »
      2 months ago, # ^ |
      Rev. 5   Vote: I like it +1 Vote: I do not like it

      just try to solve it

      \begin{equation} x+y=n \end{equation} \begin{equation} y= k*x \end{equation} \begin{equation} => n= (k+1)*x \end{equation}

      we just need k to find the value of x & y

      since (k+1) is one of the divisor of n we just search for the suitable value of k in the divisors

      for even numbers k=1 => x=y

      you can refer to my solution click here

      • »
        »
        »
        »
        2 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks a Ton!

      • »
        »
        »
        »
        2 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Can you Please Explain , how you come to conclusion y = k * x ? please