Skip to content

Instantly share code, notes, and snippets.

@gao-sun
Created March 25, 2020 12:01
Show Gist options
  • Save gao-sun/0cf4c86df18e7b88a10410b3ce37a52d to your computer and use it in GitHub Desktop.
Save gao-sun/0cf4c86df18e7b88a10410b3ce37a52d to your computer and use it in GitHub Desktop.
Lottery
#include <cstdio>
#include <cmath>
#include <cstdlib>
int hash[10000] = {0};
int main ()
{
float index;
int count;
scanf("%f%d", &index, &count);
srand(floor(index * index));
for (int i = 0; i < 50; ++ i) {
int next = 0;
while (!next) {
int tmp = rand() % count + 1;
if (!hash[tmp]) {
next = tmp;
hash[tmp] = 1;
}
}
printf("%d\n", next);
}
return 0;
}
@gao-sun
Copy link
Author

gao-sun commented Mar 27, 2020

➜ ./lottery
2772.2 368
9
165
117
73
182
290
71
314
308
5
129
343
46
162
262
279
350
329
185
63
108
8
47
253
179
12
55
128
35
144
254
98
147
154
1
306
226
49
84
297
138
203
316
194
298
11
281
215
365
192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment