fork(1) download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main(int argc, const char * argv[])
  10. {
  11. for(int count = 0;; ++count)
  12. {
  13. int cards[52];
  14. int g[5];
  15. for(int i = 0; i < 52; ++i) cards[i] = i;
  16. for(int i = 0; i < 5; ++i)
  17. {
  18. int j = rand()%(52-i)+i;
  19. int t = cards[j];
  20. cards[j] = cards[i];
  21. cards[i] = t;
  22.  
  23. g[i] = t; // i-я карта
  24. }
  25. // Проверка на наличие одинаковых карт:
  26. for(int i = 0; i < 5; ++i)
  27. for(int j = i+1; j < 5; ++j)
  28. if (g[i] == g[j]) cout << "error!\n";
  29. if (count%1000000==0) cout << count << endl;
  30. }
  31. }
  32.  
Time limit exceeded #stdin #stdout 5s 15232KB
stdin
Standard input is empty
stdout
0
1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
10000000
11000000
12000000
13000000
14000000
15000000
16000000
17000000
18000000
19000000
20000000
21000000
22000000
23000000
24000000
25000000
26000000
27000000
28000000
29000000
30000000
31000000
32000000
33000000
34000000
35000000
36000000
37000000
38000000
39000000
40000000
41000000
42000000
43000000
44000000
45000000
46000000
47000000
48000000
49000000
50000000
51000000
52000000
53000000
54000000
55000000
56000000
57000000
58000000
59000000
60000000
61000000