Search found 137 matches

by C8H10N4O2
Tue Apr 30, 2002 8:06 pm
Forum: Volume 1 (100-199)
Topic: 118 - Mutant Flatworld Explorers
Replies: 68
Views: 9602

I always do [cpp]while(scanf("%d%d",&A,&B)!=EOF)[/cpp].
by C8H10N4O2
Mon Apr 29, 2002 12:28 pm
Forum: Volume 3 (300-399)
Topic: 300 - Maya Calendar
Replies: 69
Views: 10058

Ah ha! Thank you. Sometimes the simplest details can get you:)
by C8H10N4O2
Sun Apr 28, 2002 4:12 pm
Forum: Volume 3 (300-399)
Topic: 300 - Maya Calendar
Replies: 69
Views: 10058

300 - Maya Calendar

This works for all my test cases. Anyone know of any special tricks to this problem? [cpp]#include <cstdio> #include <cstring> int ResolveMonth (char P[100]) { char X[19][10]={"pop","no","zip","zotz","tzec","xul", "yoxkin","mol","chen","yax","zac","ceh", "mac","kankin","muan","pax","koyab","cumhu", ...
by C8H10N4O2
Sun Apr 28, 2002 3:40 pm
Forum: Volume 3 (300-399)
Topic: 333 - Recognizing Good ISBNs
Replies: 166
Views: 22496

Whenever it sees an 'X', it checks to make sure it is the 10th digit, otherwise it flags the ISBN as bad.
by C8H10N4O2
Sun Apr 28, 2002 5:50 am
Forum: Volume 3 (300-399)
Topic: 333 - Recognizing Good ISBNs
Replies: 166
Views: 22496

Can someone tell me what is wrong with this code? [cpp] #include <cstdio> #include <cstring> #include <cctype> #include <vector> #include <algorithm> using namespace std; void main() { char B[1000],S[500]; bool GoodISBN; int i,j; vector<int> ISBN; while(fgets(B,1000,stdin)!=NULL) { GoodISBN=true; IS...
by C8H10N4O2
Fri Apr 26, 2002 12:31 pm
Forum: Volume 3 (300-399)
Topic: 307 - Sticks
Replies: 56
Views: 17948

Thanks! That's the exact case I was looking for. I guess I will use match checking to confirm each "i".
by C8H10N4O2
Fri Apr 26, 2002 12:29 pm
Forum: Volume 1 (100-199)
Topic: 107 - The Cat in the Hat
Replies: 278
Views: 21792

Usually TLE is caused by infinite loop. For example, what if return y is never called? Time limit exceeded :wink: [cpp]int levels(int num, int& span) { int n=0; bool finished = false; while(!finished) { n++; long x = log(num)/log(n); int y = int(x+0.5); if (num==pow(n, y)) { // n is a valid N span =...
by C8H10N4O2
Fri Apr 26, 2002 4:44 am
Forum: Volume 3 (300-399)
Topic: 307 - Sticks
Replies: 56
Views: 17948

Why doesn't this algorithm work? [cpp] #include <cstdio> void main() { int i,j,k,N,S,m; while(scanf("%d",&N)!=EOF&&N) { S=0; m=0; for(i=0;i<N;i++) { scanf("%d",&k); S+=k; if(k>m) { m=k; } } for(i=m;i<=S;i++) { if(S%i==0) { printf("%d\n",i); break; } } } }[/cpp]
by C8H10N4O2
Fri Apr 26, 2002 4:15 am
Forum: Volume 101 (10100-10199)
Topic: 10110 - Light, more light
Replies: 76
Views: 26760

Isn't ints in pascal 2 bytes? I don't know; I am C++ coder. Have you tried longs? You need unsigned longs in C++ or int64. This problem requires a unsigned 4 byte integer.
by C8H10N4O2
Fri Apr 26, 2002 4:11 am
Forum: Volume 4 (400-499)
Topic: 482 - Permutation Arrays
Replies: 159
Views: 32328

The right output for the sample input:

3 1 2
32.0 54.7 -2

should be:
54.7
-2
32.0
by C8H10N4O2
Fri Apr 26, 2002 4:01 am
Forum: Volume 1 (100-199)
Topic: 107 - The Cat in the Hat
Replies: 278
Views: 21792

Rule #1, if the judge says your answer is wrong, your solution is most likely incorrect in someway. As most Computer Scientists know, proving correctness is mighty difficult. I suggest that if you are using floating point to make sure you are incorporating epsilon. Also, make sure your input works w...
by C8H10N4O2
Thu Apr 25, 2002 5:09 am
Forum: Volume 5 (500-599)
Topic: 501 - Black Box
Replies: 35
Views: 16304

STL has all these nice ADTs:)
by C8H10N4O2
Mon Apr 22, 2002 8:24 pm
Forum: Volume 1 (100-199)
Topic: 110 - Meta-Loopless Sorts
Replies: 92
Views: 8192

I never do green problems. Special correction scares me; never got one of those AC yet...
by C8H10N4O2
Mon Apr 22, 2002 8:22 pm
Forum: Volume 1 (100-199)
Topic: 104 - Arbitrage
Replies: 223
Views: 14813

Basically, make a 3d array: FWT[x][y]

For each i, let FWT be the shortest distance between x and y using at most i steps. Use DP to build from the bottom up. And then you should be able to look up the queries.
by C8H10N4O2
Mon Apr 22, 2002 8:19 pm
Forum: Volume 5 (500-599)
Topic: 501 - Black Box
Replies: 35
Views: 16304

I was thinking about A Discipline of Programming by Edsger Wybe Dijkstra. It teachs formal algorithmic proofs that transcend time and language. He tries to teach you his thinking processes. It is a bit harder read than Skiena, but well worth it.

Go to advanced search