How to write random?

Правка ru2, от DiIzhan, 2017-10-05 07:51:51

Hi, Codeforces! I usually create a testset founded on rand (), but the range of this function is 10^5. And if I want to generate a big number, I used to write a function like this

llong randomize (llong x) {
	llong res = 1;
	for (llong i = 1; i <= 5; ++ i) {
		res *= rand () * 1LL;
		res %= x;
	} return res % x + 1;
}

but there's high probability of returning 1.

If you have an effective method of using rand () function, please, write your way.

P.S. sorry for bad english.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
ru2 Русский DiIzhan 2017-10-05 07:51:51 86
ru1 Русский DiIzhan 2017-10-05 07:50:35 497 Первая редакция (опубликовано)