fork(5) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdlib>
  4. #include <math.h>
  5. #include <time.h>
  6. using namespace std;
  7.  
  8. int main() {
  9. int i,arr[4],a=0,na=0,count=0,k,roundings=0,l,test;
  10. bool tpass;
  11. srand(time(0));
  12. for(i=1;i<1001;i++)
  13. {
  14. count=0;
  15. k=i;
  16. while(k>=1)
  17. {
  18. arr[count]=k%10;
  19. k/=10;
  20. count++;
  21. }
  22. roundings=pow(count,4);
  23. tpass=false;
  24. for(k=0;k<roundings;k++)
  25. {
  26. random_shuffle(&arr[0],&arr[count]);
  27. test=0;
  28. for(l=0;l<count;l++)
  29. test+=arr[l]*pow(10,count-1-l);
  30. if(test%11==0)
  31. tpass=true;
  32. }
  33. if(tpass==true)
  34. a++;
  35. else
  36. na++;
  37. }
  38. cout<<"Not Awesome: "<<na<<"\t Awesome: "<<a;
  39. cout<<endl<<"Required ratio: "<<double(na*pow(a,-1));
  40. return 0;
  41. }
Success #stdin #stdout 0.02s 3096KB
stdin
Standard input is empty
stdout
Not Awesome: 765	 Awesome: 235
Required ratio: 3.25532