Search found 5 matches

by porfiry czarnecki
Fri Dec 24, 2004 10:12 pm
Forum: Algorithms
Topic: Tarjan's implementation of Dijkstra's algorithm
Replies: 1
Views: 1708

Tarjan's implementation of Dijkstra's algorithm

Hello,

I have problem with implementation of algorithm for the shortest path in weighted graph, where complexity depends also on the maximum weight of the edges. In Cormen's 'Introduction to algorithms' I found, that Ahuja, Mehlhorn, Orlin and Tarjan described it in their 'Faster algorithms for the ...
by porfiry czarnecki
Wed Feb 04, 2004 11:08 pm
Forum: Volume 106 (10600-10699)
Topic: 10622 - Perfect P-th Powers
Replies: 47
Views: 31723

Great! the programme is accepted. :D
Thanks for example with -64 - I didn't consider the case with negative numbers differs from positive.
by porfiry czarnecki
Wed Feb 04, 2004 9:56 pm
Forum: Volume 106 (10600-10699)
Topic: 10622 - Perfect P-th Powers
Replies: 47
Views: 31723

You are right. Now I run 'check' with absolute value. I have also considered if x < 0 and p is even - then the procedure returns p=1.
The programme works over 0,5 sec longer. After this time it gives WA.
I used int64 instead of longint but it didn't help.

program p10622(input, output);
type int ...
by porfiry czarnecki
Wed Feb 04, 2004 8:08 pm
Forum: Volume 106 (10600-10699)
Topic: 10622 - Perfect P-th Powers
Replies: 47
Views: 31723

At first I define x as a longint type but i got WA. In the text of the problem is written:

The value of x will have magnitude at least 2 and be within the range of a (32-bit) int in C, C++, and Java

... so I changed x into a cardinal type but the same error has occured.
I didn't know that RE is ...
by porfiry czarnecki
Wed Feb 04, 2004 5:06 pm
Forum: Volume 106 (10600-10699)
Topic: 10622 - Perfect P-th Powers
Replies: 47
Views: 31723

10622 (perfect p-th powers)

I don't get it. I thought this problem is quite easy but I'm still getting wrong answer. What am I doing not in the proper way?


program p10622(input, output);
var x : cardinal;

procedure check(x : cardinal);
var j : cardinal; i,k,nr,max : cardinal;
begin
max := 1;
for i := 2 to round(sqrt(x)) do ...

Go to advanced search