diff options
Diffstat (limited to 'random.cpp')
-rw-r--r-- | random.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/random.cpp b/random.cpp new file mode 100644 index 0000000..92a3c4c --- /dev/null +++ b/random.cpp | |||
@@ -0,0 +1,18 @@ | |||
1 | |||
2 | long long rand_state = 24; | ||
3 | long long rand_para1 = 37; | ||
4 | long long rand_para2 = 37; | ||
5 | |||
6 | int randn() | ||
7 | { | ||
8 | rand_state = (rand_state*rand_state + rand_state*rand_para1 +rand_para2)%15555557; | ||
9 | return rand_state; | ||
10 | } | ||
11 | |||
12 | //seed with number from 0 to 672 | ||
13 | void srandn(int seed) | ||
14 | { | ||
15 | rand_state = seed + 2753; | ||
16 | |||
17 | randn(); | ||
18 | } | ||