Advertisement
a53

XYZ

a53
Apr 14th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <fstream>
  2. #define ULL unsigned long long int
  3. #define L 32768
  4. using namespace std;
  5. int a[L];
  6.  
  7. int nr_bit1(int n)
  8. {
  9. int nrb1=0;
  10. while(n)
  11. nrb1+=n%2,n>>=1;
  12. return nrb1;
  13. }
  14.  
  15. int main()
  16. {
  17. int n,A,B,C,D,E,F;
  18. ifstream f("countbits.in");
  19. for(int i=1;i<L;++i)
  20. a[i]=nr_bit1(i);
  21. f>>n>>A>>B>>C>>D>>E;
  22. ULL rez=a[A/L]+a[A%L]+a[B/L]+a[B%L];
  23. for(int i=3;i<=n;++i)
  24. F=1+(1ULL*A*C+1ULL*B*D)%E,rez+=a[F/L]+a[F%L],A=B,B=F;
  25. f.close();
  26. ofstream g("countbits.out");
  27. g<<rez<<'\n';
  28. g.close();
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement