fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int x=0,n,i,z;
  10. cin>>n;
  11. z=n;
  12.  
  13. while(z>2)
  14. {
  15. z=z/2;
  16. x++;
  17. }
  18.  
  19.  
  20. cout << n-pow(2,x) << endl;
  21. int suma;
  22. suma=n-pow(2,x);
  23.  
  24.  
  25. for (int i=1; suma>2; i++)
  26. {
  27. int z=0;
  28. int pomocnicza;
  29. pomocnicza=suma;
  30. while (pomocnicza > 2)
  31. {
  32. pomocnicza/=2;
  33. z++;
  34.  
  35.  
  36.  
  37. }
  38. suma=n-pow(2,x-i);
  39. }
  40.  
  41. return 0;
  42. }
  43.  
Time limit exceeded #stdin #stdout 5s 3472KB
stdin
Standard input is empty
stdout
6.7406e+07