## Search found 90 matches

Mon Oct 04, 2004 2:40 am
Forum: Algorithms
Topic: ICPC Warmup mobius function
Replies: 4
Views: 1499
Ah. Thanks for the responses. This is exactly the strategy I used, but after asking a friend he told me my way of calculating mu wasn't efficient enough (I actually factored each number from 1 to 1000000 instead of writing down a factor in the array when sieving).
Sun Oct 03, 2004 3:38 pm
Forum: Algorithms
Topic: ICPC Warmup mobius function
Replies: 4
Views: 1499

### ICPC Warmup mobius function

Hey, what is the strategy for doing the mobius function problem efficiently? I see how to determine mu(i) efficiently, but i find M(i) to be the problem. I can see how many non-square-free numbers there are less than i, but how do you deal with checking how many sqyare-free numbers less than i have ...
Thu Sep 09, 2004 2:01 pm
Forum: Algorithms
Topic: A number problem
Replies: 14
Views: 3592
have you tried iterative deepening on this problem ?

i do not know how well it will perform since i have no bound on how many operations the answer will be, but it's worth a try maybe
Tue Sep 07, 2004 1:58 pm
Forum: Volume 4 (400-499)
Topic: 492 - Pig-Latin
Replies: 213
Views: 25974
i have not read all ur code, but i see u make the assumption that each line is no longer than 10,000 characters. i am not sure you can assume this. gl. P.S. if any admins see this, i think the juge is missing some critical test inputs for this problem i wrote a program that did the following and it ...
Tue Sep 07, 2004 11:54 am
Forum: Volume 107 (10700-10799)
Topic: 10710 - Chinese Shuffle
Replies: 19
Views: 4633
isn't that like cheating?:)
Mon Sep 06, 2004 5:11 pm
Forum: Volume 4 (400-499)
Topic: 454 - Anagrams
Replies: 97
Views: 21507
edit: i switched to C++ and used string to avoid a static array since the input constraints don't say how long each word is to get AC.

[c]
CUT
[/c]
Mon Sep 06, 2004 4:34 pm
Forum: Volume 4 (400-499)
Topic: 459 - Graph Connectivity
Replies: 132
Views: 25182
don't let the habit of always having < or >= in for loops mess you up too

[c]
AC
[/c]
Mon Sep 06, 2004 2:51 am
Forum: Algorithms
Topic: Prime Number
Replies: 8
Views: 1690
why mod by even things ? just check mod by 2 in the beginning then you can speed things up by a factor of 2.

[c]
int i;
if (n<2) return 0;
else if (!(n&1)) return n==2;
else {
for (i=3;i*i<=n;i+=2) if (!(n%i)) return 0;
return 1;
}

[/c]
Sun Sep 05, 2004 10:37 pm
Forum: Volume 5 (500-599)
Topic: 571 - Jugs
Replies: 24
Views: 12716
I tried to use BFS to solve this problem, but got SIGSEV. Does anyone see what is wrong? I've tried littering the code with asserts, but it was no help. :( The idea of my code is to keep track of which states have been visited in the states array. states [j][2] is 0 iff we haven't visited the state ...
Sun Sep 05, 2004 8:08 pm
Forum: Volume 4 (400-499)
Topic: 447 - Population Explosion
Replies: 23
Views: 2335
here's some shorter I/O. you can email/message me if you want more though. warning: I got PE on this problem so when you check your output against mine you should ignore extra whitespace (i'm not quite sure why i got PE. anyone see why?) Input: 2 5 1 1 1 2 2 1 20 19 20 20 19 20 18 20 5 4 5 6 4 5 10 ...
Sun Sep 05, 2004 7:32 pm
Forum: Volume 4 (400-499)
Topic: 447 - Population Explosion
Replies: 23
Views: 2335
hm, i haven't taken the time to reason through your code because it is so long (why so complicated?). my ac code is only 51 lines (of which 3 are just method declarations and 15 others just have a }). do you have email for me to send you I/O? or if you use AIM/MSN messenger i am MinilekDOC on AIM an...
Sat Sep 04, 2004 6:18 pm
Forum: Volume 101 (10100-10199)
Topic: 10189 - Minesweeper
Replies: 418
Views: 68193
your code has many special cases and is kind of ugly to read. consider wrapping your minesweeper map by a frame of .'s to avoid all special cases e.g. if u have a 3x3 minesweeper board, but a 5x5 frame around it ..... . . . . . . ..... my code is 30 lines by doing this, and it makes things much easi...
Tue Aug 31, 2004 11:24 pm
Forum: Volume 107 (10700-10799)
Topic: 10706 - Number Sequence
Replies: 34
Views: 14318
[c]
AC