Filehost.ro - gazduire fisiere
ITWORLD
Probleme functionare hardware si software ? Le aflati raspunsul aici !
Nou pe simpatie:
andrum94 24 ani
Femeie
24 ani
Galati
cauta Barbat
27 - 80 ani
ITWORLDReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
ITWORLD / C++ / C# /

Tabele de dispersie (HashTabel)

Pagini: 1  
#1
ariant
Administrator
Deschid un concurs !!! Cine reuseste sa implementeze un algoritm pentru crearea unei tabele de dispersie. Iata si cateva functii de hash pentru ajutor:
A) pentru numere intregi:

    * h(x) = x % M
    * h(x) = (x * r) % M , r - numar aleator ales la inceputul programului

B)

    * h(x , i) = ( h'(x) + i ) % M
    * h(x , i) = ( h'(x) + r1 * i + r2 * i^2 ) % M
    * h(x , i) = ( h1(x) + i * h2(x) ) % M

r1, r2 - numere alese aleator la inceputul programului.
C) pentru numere reale

    * h(x) = [ {a * x} * M ] , 0 < a < 1

{x} - partea fractionara a lui x; [x] = partea intreaga a lui x; [x] + {x} = x - prin definitie;

a este un numar care trebuie ales inainte sau la inceputul rularii programului; alegerea lui influenteaza eficienta functiei; Knuth propune urmatoarea valoare pentru a : ( sqrt(5) - 1 ) / 2 ~ 0.6180339887...


Iata si cateva probleme:

* Problema 1:
People of country T-land lived on the big plain many years ago. It is happened so that they started to quarrel, so they began to build walls to separate from each other.
One day they realized that walls surround some part of the country. Your task is to determine which wall was build first to surround a part of the T-land.

Input
The first line of input contains one number M (1<=M<=200000) - number of walls. Each of the following M lines contains four integer numbers: Cartesian coordinates of two ends of each wall. Walls are rectilinear segments with positive length, two walls can cross only by ends, and walls can't coincide. All coordinates do not exceed 10^9 by its absolute values.

Output
Write the answer in the single line of output. If all the walls leave the territory opened, write 0.

Sample test(s)

Input: 4
0 0 1 0
0 1 0 0
1 0 0 1
2 2 5 7

Output: 3

* Problema 2:
For given N and pair (A0, B0) find all pairs (A, B) such that for any integer X and Y if A0X+B0Y is divided by N then AX+BY is divided by N too (0<=A,B<N).

Input
Each input consists of positive integer numbers N, A0 and B0 (N,A0,B0£ 10000) separated by whitespaces.

Output
Write number of pairs (A, B) to the first line of output. Write each pair on a single line in order of non-descreasing A (and B in case of equal A). Separate numbers by single space.

Sample Input

3
1 2

Sample Output

3
0 0
1 2
2 1

Spor la treaba !


 
   
#2
MicMan
Moderator
Din: Ploiesti
Si ce premii pui in joc ??? Ca daca e pe degeaba... au mai fost si altii !!

_______________________________________
Viata ar fi mai simpla daca i-am vedea codul sursa...

 
   
#3
ariant
Administrator
pun la bataie o sticla de wisky ... invingatorul alege marca

 
   
Pagini: 1  
Mergi la