Search found 95 matches

by cytmike
Sun Jan 09, 2005 5:11 am
Forum: Volume 107 (10700-10799)
Topic: 10790 - How Many Points of Intersection?
Replies: 28
Views: 16483

The formula is very trivial as long as you know how to sum up Arithmetic Progression.
Just list all the small cases of P(m,n) and you can find out the formula. :lol:
by cytmike
Fri Oct 22, 2004 4:49 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

BiK wrote:How on earth are you using hash_map? This class is not part of the C++ standard.

What on earth should I use then....
by cytmike
Fri Oct 01, 2004 6:27 pm
Forum: Volume 102 (10200-10299)
Topic: 10217 - A Dinner with Schwarzenegger!!!
Replies: 28
Views: 9301

So that means every people compare with the ticket seller as well?
And then p(i)=(1-sum(p(1..i-1)))*i/N ?

So my previous idea is wrong?
by cytmike
Fri Oct 01, 2004 5:48 pm
Forum: Off topic (General chit-chat)
Topic: Did the Judge System Crash?
Replies: 3
Views: 1974

My solved problems are all gone, becomes 0 submission.
What happened?
by cytmike
Sun Jul 25, 2004 5:41 am
Forum: Volume 106 (10600-10699)
Topic: 10620 - A Flea on a Chessboard
Replies: 10
Views: 5423

I finally got AC. :D. It works with my formula for the number of steps, thought I wrote it wrong in the previous post. It is in fact lcm( S/gcd(S,dx), S/gcd(S,dy)). Can you tell what's the logic behind the formula? I'm quite weak in number theory.. S / gcd(S,dx) --> what does this means? S / gcd(S,...
by cytmike
Mon Jul 19, 2004 9:58 am
Forum: Volume 102 (10200-10299)
Topic: 10217 - A Dinner with Schwarzenegger!!!
Replies: 28
Views: 9301

Re: my idea to clarify the problem compared with dumb dan's

To clarify the problem: Exactly one person in the ticket queue will win. A person will win if no person in front of him has won AND his/her birthday is the same as ANY one of the people in front of him. So if there are N days in the year the first person will have a probability p(1)=1/N to win, sec...
by cytmike
Mon Jul 19, 2004 7:15 am
Forum: Volume 105 (10500-10599)
Topic: 10521 - Continuously Growing Fractions
Replies: 17
Views: 6276

There may be at most 2000 digits in both P and Q.
by cytmike
Mon Jul 19, 2004 6:16 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

I changed my code to this in order to do string hashing, but the judge gives me compile error while i can correctly compile using gcc, why? [cpp]#include <string> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <locale.h> #include <algorithm> #include <hash_map.h...
by cytmike
Fri Jul 16, 2004 6:01 pm
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

So you use your own hash fucntion? I don't know why there is some problem with STL hash_map with const char* I guess hash_map is actually using pointer to char, not array of chars as a key (It's definetely true for set, I checked it). You should try to use string. BTW, hash I'm using is very easy t...
by cytmike
Fri Jul 16, 2004 5:49 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

Your last code results in WA because it always prints 0.0000. (at least for me) cout is fast enough for this problem: I've just moved to second place with 0.8sec, still using cout for output... So you use your own hash fucntion? I don't know why there is some problem with STL hash_map with const ch...
by cytmike
Fri Jul 16, 2004 5:28 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

I don't know, I use printf instead of cout, but otherwise, everything looks the same.. I use .clear() instead of reallocating the memory.. don't know which is faster.. [] is different from .find in that if the key is not in the map, it'll create it, while in .find, it'll just return 0. In this case...
by cytmike
Fri Jul 16, 2004 5:08 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

I changed to use hash_map I get WA in 5s... What happens? [cpp]#include <string> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <algorithm> #include <hash_map.h> using namespace std; struct cs { string p; char h[31]; }; bool sillyhp(cs p,cs h...
by cytmike
Fri Jul 16, 2004 4:22 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

My code is here. As you can see, I don't need to clear as the map is destroyed after each case. [cpp] #include <string> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <map> using namespace std; int main() { int p; cin>>p; char h[3000]; gets(h...
by cytmike
Fri Jul 16, 2004 2:47 am
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

I do something like this here.
But I still got TLE... What happens??
If I just read data, its 1.3s.
But if I put them in the map, it's TLE already.
:cry: :cry:

[cpp]map <string,int> sky;

int size=0;
while (gets(h)&&strlen(h))

{
size++;
sky[(string)h]++;
} [/cpp]
by cytmike
Thu Jul 15, 2004 7:39 pm
Forum: Volume 102 (10200-10299)
Topic: 10226 - Hardwood Species
Replies: 121
Views: 38508

I used this:

[cpp]hash_multiset <char*> sky;
cin.getline(h,32);
while (strlen(h))
{
sky.insert(h);
cin.getline(h,32);
}[/cpp]

a set of pointers? why? what should i do then? convert c-styled char array to c++ string first?

Go to advanced search