

















input
output5000
2000
9999
And my max limit is 9999,13 / 64
41 / 2
91 / 10
min one is 0.
I got W.A. at 1.6...seconds.
Moderator: Board moderators
output5000
2000
9999
And my max limit is 9999,13 / 64
41 / 2
91 / 10
I agree, it would be better if a range is given.But why the problem didn't point out the range
Sorry, my fault, I should have told you the exact limit I used (I checked if I have more than 500000 values only when I computed next row/column. Therefore my exact limit is 500071.I got W.A. ----- array[500000]----limit 499999;
Code: Select all
0
1
2
3
4
5
6
7
8
9
10
101
2000
2521
5000
9999
30101
499999
500000
509990
509999
510000
Code: Select all
1 / 1
0 / 1
-1 / 1
-2 / 1
2 / 1
1 / 2
-1 / 2
-3 / 2
-3 / 1
3 / 1
3 / 2
5 / 9
41 / 2
-46 / 25
13 / 64
91 / 10
-19 / 157
72 / 641
71 / 641
-374 / 647
-383 / 647
-384 / 647
You can just directly simulate the whole process as problem defined, and prune the undesired rational spiral numbers.eloha wrote:Can anyone tell me how to solve 493 Rational Spiral ?
I have no idea at all. Thanx.
idea here : http://www.youngprogrammer.comeloha wrote:Can anyone tell me how to solve 493 Rational Spiral ?
I have no idea at all. Thanx.
Code: Select all
bool vis[1500][1500]; // will be able to hold for inputs upto 510000
...
// checking part
if( den!=0 && vis[num+750][den+750]==false ){ // +750 for offset on negative numbers
vis[num+750][den+750] = true; // visit
... // add fraction to your list
}