fork(1) download
  1. #include <stdio.h>
  2.  
  3. int div3(int x){
  4. const int t[]={0,0,0,1,1,1,2,2,2,3};
  5. //int y = (x>>2) + (x>>4) + (x>>6); // max error is 12 of done one-line
  6. int y = (x>>2) + (x>>4);
  7. y+=y>>4;
  8. int b = x - (y<<1) - y;
  9. y+=(t[b]);
  10. return y;
  11. }
  12.  
  13. int main(void) {
  14. for(int i=0;i<=255;i++){
  15. int y = div3(i);
  16. if(y!=i/3){
  17. printf("%d vs %d at %d\n", y, i/3, i);
  18. }
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5520KB
stdin
Standard input is empty
stdout
Standard output is empty