1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

p, q, r | 16 Sep 2009

Discussion in '$1 Daily Competition' started by shabbir, Sep 16, 2009.

  1. shabbir

    shabbir Administrator Staff Member

    X is positive integer of the form pqpqpqrq, such that (X-1) is a perfect square;

    where p, q and r different digits from 0 to 9, with p being nonzero.

    Determine X
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Possible solutions ::

    45454565
    82828202

    :D
     
  3. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Brute-force solution :

    Code:
    #include <stdio.h>
    #include <math.h>
    
    int main()
    {
        unsigned int p,q,r, Num, SNum;
        for(int p = 1; p < 10; ++p)
        {
            for(int q = 0; q < 10; ++q)
            {
                for(int r = 0; r < 10; ++r)
                {
                    // pqpqpqrq
                    Num = p*(10101000);
                    Num += q*(1010101);
                    Num += r*10;
    
                    Num -= 1;
    
                    SNum = floor(sqrt(Num));
    
                    if(SNum * SNum == Num) {printf("p=%d q=%d r=%d\nX=%d\nX-1=%d\nsqrt(X-1)=%d\n\n", p,q,r,Num+1,Num,SNum);}
                }
            }
        }
        return 0;
    }
    Output ::

    Code:
    p=4 q=5 r=6
    X=45454565
    X-1=45454564
    sqrt(X-1)=6742
    
    p=8 q=2 r=0
    X=82828202
    X-1=82828201
    sqrt(X-1)=9101
    
    Process returned 0 (0x0)   execution time : 0.031 s
     
  4. shabbir

    shabbir Administrator Staff Member

    I knew not many would attempt on this one. Congrats SP
     
  5. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

Share This Page