Hello alaiyeshi,
Thursday, November 2, 2006, 9:26:37 PM, you wrote:
I've met replicateM_ for the first time;-) This could be a
template for doing online-judge exercises I guess. And it's very useful for
newbies like me.
make an date for 'interact' :)))
--
Best regards,
Bulat
Wow! Thank you for your suggestion.
But I guess in this problem the first input line and the other are different in
their meaning. Thus if I use interact I should parse the input(again), I
guess.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hello alaiyeshi,
Friday, November 3, 2006, 4:23:40 PM, you wrote:
But I guess in this problem the first input line and the other are
different in their meaning. Thus if I use interact I should parse the
input(again), I guess.
it seems that you don't understand that functional programming
Thank you for replying.
Smart method! I've learned much;-) I'll have a try using UArray.
Also, I guess my code still waste too much time parsing input (I compiled my
code with -prof flag on)...
Maybe ByteString may save me (or a smarter brain), What is your opinion about
doing faster IO,
Thank you so much!
I've met replicateM_ for the first time;-) This could be a template for doing
online-judge exercises I guess. And it's very useful for newbies like me.
Again many Thanks:-)___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On 11/2/06, Spencer Janssen [EMAIL PROTECTED] wrote:
On Nov 2, 2006, at 8:48 AM, alaiyeshi wrote:
Also, I guess my code still waste too much time parsing input (I
compiled my code with -prof flag on)...
Maybe ByteString may save me (or a smarter brain), What is your
opinion about doing
Hi
I'm new to Haskell.
I found this site on the Haskell wiki https://www.spoj.pl. But I got some
trouble on trying to solve the problem titled Prime Generator
https://www.spoj.pl/problems/PRIME1.
The online-judge system tells me time limit excedded
Would you be so kind to tell me how to make
I didn't see any other replies and didn't want to leave you hanging, so...
Three hints:
1) you are testing every integer = 2 as a divisor when you only need to
test prime numbers = floor(sqrt(n))
2) Since for all n 2, floor(sqrt(n)) n, you can use the very primes
you are generating in the
Two more hints I used in my code:
5) Except for 2, all primes are odd. Don't bother testing the evens.
6) sqrt(n) is (a little) costly, but I used it in my first solution for
clarity. You can also create an infinite list of squares of primes, then
trim the list of primes to the length of
Thanks a lot.
(you really spoil me;-))
What a stupid mistake I've made!(flush)
I'll rewrite my code later.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
The problem with your approach is the gratuitous use of division,
which tends to be very slow.
In my solution, I first generate a list of seed primes, all primes
less than sqrt 10. Then, for each input m and n, I generate
all multiples of the seed primes between m and n. I then
11 matches
Mail list logo