fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. unsigned CountBefore(unsigned N) { return (N-1)/3+1; }
  5. unsigned CountBetween(unsigned A,unsigned B) { return CountBefore(B)-(A?CountBefore(A-1):0); }
  6.  
  7. int main()
  8. {
  9. cout<<CountBetween(1,20)<<endl;
  10. cout<<CountBetween(21,1000)<<endl;
  11. cout<<CountBetween(1001,1000000)<<endl;
  12. cout<<CountBetween(1000001,10000000)<<endl;
  13. cin.get(); // jeżeli tego potrzebujesz to zmień IDE
  14. return 0;
  15. }
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
2863311537
327
333000
3000000