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=1;
  9. while (Exp<Len)
  10. Exp*=2;
  11. if (X==1&&Y==1)
  12. {
  13. return 1;
  14. }
  15. else if (X>Exp/2&&Y>Exp/2)
  16. {
  17. return (Exp*Exp/4)+Reduce(X-Exp/2,Y-Exp/2);
  18. }
  19. else if (X>Exp/2&&Y<=Exp/2)
  20. {
  21. return 2*(Exp*Exp/4)+Reduce(X-Exp/2,Y);
  22. }
  23. else if(X<=Exp/2&&Y>Exp/2)
  24. {
  25. return 3*(Exp*Exp/4)+Reduce(X,Y-Exp/2);
  26. }
  27. }
  28. int main()
  29. {
  30. unsigned long long int I,J;
  31. scanf("%llu%llu",&I,&J);
  32. printf("%llu\n",Reduce(J,I));
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.02s 2728KB
stdin
Standard input is empty
stdout
402392407156292054