fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <stdlib.h>
  4. typedef uint64_t u64;
  5.  
  6. void nvme_u64_div(u64 dividend, u64 divisor)
  7. {
  8. u64 quotient = 0;
  9. u64 remainder = 0;
  10. int i;
  11.  
  12. for (i = 63; i >= 0; i--) {
  13. remainder = (remainder << 1) | ((dividend >> i) & 1);
  14. if (remainder >= divisor) {
  15. remainder -= divisor;
  16. quotient |= (1ULL << i);
  17. }
  18. }
  19. printf("%d\n",quotient);
  20. }
  21. int main(void) {
  22. // your code goes here
  23. nvme_u64_div(12345678901234567890ULL,98765432109876543ULL);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
124