fork(5) download
  1. <?php
  2. function randP($p) {
  3. if (($r=rand(0, 99)) <($p-1)) return 2; // 80% случаев
  4. //else не надо
  5.  
  6.  
  7. if (($r = ((int) (($r-$p)/20*9))+1) < 2) return $r; //1
  8. return ($r+1);
  9. }
  10. for ($i=0;$i<100;$i++) {
  11. echo randP(80)."\n";
  12. }
  13.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
7
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
5
2
2
2
2
2
2
2
2
3
3
8
2
2
2
2
2
2
2
2
2
2
10
1
2
2
2
2
2
2
2
2
2
9
2
2
2
1
2
2
2
8
2
2
2
2
2
2
7
10
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
3
2
2
2
2
2
2
2
2
2