fork download
  1. #include <cmath>
  2. #include <fstream>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. bool isSimple(long long num);
  7. double OPCount = 0;
  8.  
  9. int main()
  10. {
  11. long num = 0;
  12. if(isSimple(12312449))
  13. cout<<num<<" SIMPLE ";
  14. else
  15. cout<<num<<" NOT SIMPLE ";
  16. return 0;
  17. }
  18.  
  19. bool isSimple(long long num)
  20. {
  21. long long i = 0;
  22. bool bSimple = true;
  23. if( num < 0 )
  24. num *= -1;
  25. OPCount += 1;
  26. for(i = 2; i <= 9 && bSimple; i++)
  27. {
  28. OPCount += 1;
  29. if( i != num )
  30. bSimple = num % i != 0;
  31. }
  32. for(i = 9 + 2; i <= 256 && bSimple; i += 2)
  33. {
  34. if( i != num )
  35. bSimple = num % i != 0;
  36. if(!bSimple)
  37. cout<<"DIVIDER : "<<i<<endl;
  38. OPCount += 1;
  39. }
  40. return bSimple;
  41. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
DIVIDER : 47
0 NOT SIMPLE