fork download
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. const int N = 100000 + 10;
  5. int t, n, a[N];
  6. int g=3;
  7. ll f;
  8. ll ans;
  9. int main() {
  10. f=(ll)g;
  11. printf("g=%d\tf=%lld\n",g,f);
  12. scanf("%d", &t);
  13. while (t--) {
  14. ans = 0;
  15. scanf("%d", &n);
  16. for (int i = 0; i < n; ++i)
  17. scanf("%d", a + i);
  18. for (int k = 0; k <= 20; ++k) {
  19. int cnt = 0;
  20. for (int i = 0, v; i < n; ++i) {
  21. v = (a[i] >> k) & 1;
  22. // printf("a dec=%i\tV=%i\n",a[i] >> k,v);
  23. if (v) {
  24. ++cnt;
  25. }
  26. else {
  27. ans += (ll) cnt * (cnt + 1) / 2 * (1 << k);
  28. // printf("cnt=%i\t1<<k=%i\tresult=%d\n",cnt,1<<k,cnt*(cnt+1)/2*(1<<k));
  29. printf("a=%i\tcnt=%i\t1<<k=%i\tans=%lld\n",a[i],cnt,1<<k,ans);
  30. cnt=0;
  31. }
  32. }
  33. ans += cnt * (cnt + 1) / 2 * (1 << k);
  34. }
  35. printf("%lld\n", ans);
  36. }
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
4
11 9 6 11
compilation info
prog.c:1:25: fatal error: bits/stdc++.h: No such file or directory
 #include <bits/stdc++.h>
                         ^
compilation terminated.
stdout
Standard output is empty