fork download
  1. #include <iostream>
  2. using namespace std;
  3. const int maxi=1001;
  4. int a[1001];
  5. int count(int n){
  6. int c=0;
  7. while(n>0){
  8. c+=n&1;
  9. n>>=1;
  10. }
  11. return c;
  12. }
  13. void pre(){
  14. for(int i=1;i<=maxi;i++){
  15. a[i]=a[i-1]+count(i);
  16. }
  17. }
  18. int main() {
  19. // your code goes here
  20. int n=1;
  21. cout<<a[n]<<endl;
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5504KB
stdin
4
stdout
0