Search found 67 matches

by dumb dan
Sun May 29, 2005 10:45 pm
Forum: Volume 1 (100-199)
Topic: 107 - The Cat in the Hat
Replies: 278
Views: 20107

In my AC solution I used long long when the input fit into a long long,
otherwise I used a simple form of biginteger.
Bottom line is, you have to handle those large inputs with something else than a long long.
by dumb dan
Sat May 28, 2005 12:11 am
Forum: Volume 108 (10800-10899)
Topic: 10854 - Number of Paths
Replies: 25
Views: 9126

Perhaps this answers your questions?

input:

Code: Select all

4
ENDPROGRAM
S
ENDPROGRAM
IF
ELSE
END_IF
ENDPROGRAM
IF
ELSE
IF
ELSE
END_IF
END_IF
ENDPROGRAM
output:

Code: Select all

1
1
2
3
by dumb dan
Fri May 27, 2005 4:04 pm
Forum: Volume 105 (10500-10599)
Topic: 10578 - The Game of 31
Replies: 11
Views: 4945

Always consider the worst case. I'm guessing the worst case for you would be if input is simply "1".

To avoid computing the same thing over and over again, try to consider the fact that it doesn't matter in what order the previous cards have been played in.
by dumb dan
Wed May 25, 2005 1:26 pm
Forum: Volume 107 (10700-10799)
Topic: 10780 - Again Prime? No Time.
Replies: 40
Views: 27291

My algorithm is: 1. generate primes in range [2...5000] 2. for each M,N pair - factorize M using prime table from step 1 - factorize N! using prime table from step 1 - output (power of max prime in M in N!)/(power of max prime in M) if it's greater than 0 or appropriate message Is this wrong ? Only...
by dumb dan
Wed May 25, 2005 1:00 pm
Forum: Volume 5 (500-599)
Topic: 543 - Goldbach's Conjecture
Replies: 109
Views: 23993

Re: 543 - Time Limit with C, compile Error with Java. GAAAA!

for(i = 1; i<numero; i+=2) { for(j = i; j<numero; j+=2) { if(isPrime(i) && isPrime(j) && i+j==numero) { printf("%ld = %ld + %ld\n", numero,i,j); return 0; } } } This part of your program has complexity O(numero^2) where numero can be as big as 1000000. If you think about what you are doing a little...
by dumb dan
Tue May 24, 2005 7:25 pm
Forum: Volume 103 (10300-10399)
Topic: 10364 - Square
Replies: 47
Views: 14836

Try this test case:

input:

Code: Select all

1
19 3 3 3 9 9 9 10 17 17 17 18 18 18 19 19 19 20 20 20
by dumb dan
Mon May 23, 2005 4:52 pm
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 8552

Your current algorithm is O(n^2). You can make it O(n) if you just remove dublicates when you read the input instead of later. All you need to do is check if(counter[number]) and just don't put anything into input that already has counter>=1. If you want to solve problems faster, you need to think m...
by dumb dan
Sat May 21, 2005 3:57 pm
Forum: Volume 108 (10800-10899)
Topic: 10845 - The crusades
Replies: 4
Views: 2171

I haven't really thought alot about this problem, but isn't it some kind of variant of the knapsack problem?
by dumb dan
Fri May 20, 2005 11:57 am
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 8552

an array sized twice the biggest number in input This is what I meant by input being nice. There's no mentioning of a limit to the input numbers in the problem description. I wouldn't want to allocate that array if the biggest number is, say 2^30. I can only assume by your post this wasn't the case...
by dumb dan
Thu May 19, 2005 6:21 pm
Forum: Volume 100 (10000-10099)
Topic: 10036 - Divisibility
Replies: 37
Views: 10849

this input:

Code: Select all

1
4 9
8 2 3 4
should yield this output:

Code: Select all

Divisible
since 8+2+3-4=9
by dumb dan
Thu May 19, 2005 11:27 am
Forum: Volume 100 (10000-10099)
Topic: 10036 - Divisibility
Replies: 37
Views: 10849

int a[105][105]={0};
...
for(int i=1;i<N;i++)
...
a[temp]=1;

N might be much larger than 105
by dumb dan
Thu May 19, 2005 8:32 am
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 8552

> That Is If The 3.i Take It To Input array & To The Sorted Array And Incress counter[3]++; What do you mean by this? Do you mean if the input is '3' you increase counter[3]++;? Or do you mean that if the input number is equal to the fourth element of the input array (element inpt[3]) you increase ...
by dumb dan
Wed May 18, 2005 9:00 am
Forum: Volume 6 (600-699)
Topic: 637 - Booklet Printing
Replies: 10
Views: 4024

I think if you solve this case correctly, you'll likely solve all cases correctly:

input:

Code: Select all

5
0
output:

Code: Select all

Printing order for 5 pages:
Sheet 1, front: Blank, 1
Sheet 1, back : 2, Blank
Sheet 2, front: Blank, 3
Sheet 2, back : 4, 5
by dumb dan
Mon May 16, 2005 4:57 pm
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 8552

Of course they also do a lot of fair optimizing and of course they are good programmers. Maybe you know something I don't, but I think their submission stats speak for themselves. If they wanted to optimize their code they could do it on their own machines (I'm certain they are more than capable of ...
by dumb dan
Mon May 16, 2005 11:04 am
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 8552

First of all you should note that both "Scott E August" and "Ivor L66bas" have more than 100 submissions for every solved problem. What they do is they "probe" the judge input. When you know what input there will be, it's much easier to write a program that will get a quick AC. If you ask me this is...

Go to advanced search