Afişează mesaje
|
Pagini: [1] 2 3 ... 47
|
1
|
Comunitate - feedback, proiecte si distractie / Blog / Răspuns: Problem: Shoe laces
|
: Aprilie 28, 2016, 12:43:19
|
Not 100% sure but I think this is equivalent with the expected number of cycles in a random permutation of size N.
Also I think the answer is N / 2, not proof of this yet, just a wild guess, because I have a feeling that P(i) = Probability you have i cycles = P(N - i + 1) (in other words the probability of having i cycles is the same as the probability N - i + 1 cycles).
|
|
|
2
|
Comunitate - feedback, proiecte si distractie / Feedback infoarena / Răspuns: Avertismente cstdin
|
: Ianuarie 29, 2015, 14:42:03
|
Functia freopen returneaza si o valoare de tip FILE. Basically cand dai freopen("ana.in", "r", stdin)
functia freopen iti intoarce un pointer la stdin in cazul in care a reusit sa deschida fisierul si null daca nu. Warningul apare din cauza ca tu ignori valoarea returnata, daca inlocuiesti codul de mai sus cu FILE* f = freopen("ana.in", "r", stdin) if (f == null) { printf("Could not open file"); return 0; }
ar trebui sa nu mai apara warningu asta.
|
|
|
18
|
Comunitate - feedback, proiecte si distractie / Blog / Răspuns: Numbers everyone should know
|
: Martie 26, 2013, 16:46:51
|
This is awesome.
Towards the end of my programing contests career I used to know this list, but not because someone told it to me but because of experience. Also I think there are also several exceptions to the rule. For example topcoder problems always have n=50. Also one of the best experiences I had solving a task was on the task called "tgraf" from infoarena where I managed to figure out the solution because of the restricion on n (n was maximum 20).
|
|
|
21
|
Comunitate - feedback, proiecte si distractie / Blog / Răspuns: count(distinct)
|
: Octombrie 24, 2012, 13:30:36
|
Prima ideea care mi-a trecut prin cap ar fi sa impart intervalu [1 .. 2^64] in K intervale (K-ul cel mai mic posibil astfel incat sa pot stoca 2^64 / K int-uri). Iterez prin fisier si vad cate numere apar in fiecare interval. Dupa asta as vrea sa estimez in fiecare interval cate duplicate sunt stiind cate numere sunt acolo si lungimea intervalului. Pentru asta m-as folosi de expected number of duplicates. Mai exact as incerca sa calculez pentru un interval:
expected_number_of_duplicates = 1 * P[1] + 2 * P[2] + 3 * P[3] + ... (P[x ] - probabilitatea sa existe x duplicate in cadrul intervalului).
Suma finala a expected_number_of_duplicates din fiecare interval ar fi un rough estimate al numarului de duplicate din fisier. Solutia se imbunatateste destul de mult cu cat creste memoria (daca pot sa stochez mai multe intervale atunci estimarea se imbunatateste), insa pentru 1024 bytes cred ca numarul de intervale e prea mic si estimarea s-ar putea sa fie foarte departe.
Will keep thinking.
|
|
|
24
|
Comunitate - feedback, proiecte si distractie / Blog / Răspuns: Meet in the middle
|
: August 17, 2012, 09:24:37
|
@S7012MY: There are way more than 9 solutions.
6) You can do 2 BFS in the same time. Let's say you start with 2 queues. First one contains the starting point (the initial configuration), the second one contains the ending point (the desired configuration). Now you can just expand the nodes alternatively (expand a node from the first queue, then from the second queue and so on). Everytime you try to insert a node in it's queue, you check if that node isn't already in the other queue. If so then you found your solution.
|
|
|
|