# p, q, r | 16 Sep 2009

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

Joined:
Jul 12, 2004
Messages:
15,296
366
Trophy Points:
83
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~ Б0ЯИ Τ0 С0δЭ ~

Joined:
May 5, 2009
Messages:
1,343
55
Trophy Points:
0
Occupation:
STUDENT !
Location:
Orissa, INDIA
Possible solutions ::

45454565
82828202

3. ### SaswatPadhi~ Б0ЯИ Τ0 С0δЭ ~

Joined:
May 5, 2009
Messages:
1,343
55
Trophy Points:
0
Occupation:
STUDENT !
Location:
Orissa, INDIA
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```

Joined:
Jul 12, 2004
Messages:
15,296
366
Trophy Points:
83
I knew not many would attempt on this one. Congrats SP

Joined:
May 5, 2009
Messages:
1,343