fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. unsigned long long int Reduce(unsigned long long int X ,unsigned long long int Y)
  5. {
  6. unsigned long long int Exp,Len;
  7. Len=X>Y?X:Y;
  8. Exp=(unsigned long long int)pow(2,ceill(log2(Len)));
  9. if (X==1&&Y==1)
  10. {
  11. return 1;
  12. }
  13. else if (X>Exp/2&&Y>Exp/2)
  14. {
  15. return (Exp*Exp/4)+Reduce(X-Exp/2,Y-Exp/2);
  16. }
  17. else if (X>Exp/2&&Y<=Exp/2)
  18. {
  19. return 2*(Exp*Exp/4)+Reduce(X-Exp/2,Y);
  20. }
  21. else if (X<=Exp/2&&Y>Exp/2)
  22. {
  23. return 3*(Exp*Exp/4)+Reduce(X,Y-Exp/2);
  24. }
  25. }
  26. int main()
  27. {
  28. unsigned long long int I,J;
  29. scanf("%llu%llu",&I,&J);
  30. printf("%llu\n",Reduce(J,I));
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 1724KB
stdin
Standard input is empty
stdout
402309985468937174