fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int find(int max, int life)
  5. {
  6. int even = 0, odd = 0;
  7. //srand(time(0));
  8. int k;
  9. while(life--){
  10.  
  11. k = rand()%max;
  12.  
  13. if(k%2 ==0){
  14. even++;
  15. }
  16.  
  17. else{
  18. odd++;
  19. }
  20. k = 0;
  21. }
  22. return odd;
  23.  
  24. }
  25.  
  26. int main() {
  27. // your code goes here
  28. int max, life;
  29. cin>>max>>life;
  30. cout<<find(max, life);
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5392KB
stdin
100  200
stdout
106