fork download
  1. using namespace std;
  2. #include <bits/stdc++.h>
  3. #define ll long long
  4. #define vl vector<ll>
  5. #define vll vector<vl>
  6. #define pll pair<ll,ll>
  7. #define pb push_back
  8. #define pob pop_back
  9. #define pf push_front
  10. #define pof pop_front
  11. #define mp make_pair
  12. #define ff first
  13. #define ss second
  14. #define ret return
  15. #define mod 1000000007
  16. #define LoL printf("Lol\n");
  17. /*---------------------------------------------------------*/
  18. #define ALL(a) a.begin(), a.end()
  19. #define SIZ(x) (ll)x.size()
  20. #define REP(i,a,n) for(ll i=a;i<n;++i)
  21. #define REPA(i,a,n) for(ll i=a;i<=n;++i)
  22. #define REPD(i,a,n) for(ll i=a;i>=n;--i)
  23. #define IOS ios_base::sync_with_stdio(0);
  24. #define MEMSET(v,h) memset((v),(h),sizeof(v))
  25. /*---------------------------------------------------------*/
  26. #define MMI(a,M)
  27. #define ADD(a,b,M) (a%M+b%M)%M
  28. #define SUB(a,b,M) (a%M-b%M+M)%M
  29. #define MUL(a,b,M) (a%M*b%M)%M
  30. #define DIV(a,b,M) (MMI(b,M)*a%M)%M
  31.  
  32. /*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*/
  33.  
  34. const int N=512;
  35. int n,m,arr[N],dp[513][520];
  36.  
  37. // * dp[n][m] represent ways to get value 'm' when we consider first n elements
  38. // * We can find ways for entire arr[Size(N)] by just adding the result of previous considered arr[Size(N-1)]
  39. // * m will range from 0 to max possible value that can be formed by xoring any numbers from array
  40.  
  41. int main()
  42. {
  43. cin >> n >> m;
  44.  
  45. REP(i,0,n) cin >> arr[i];
  46. REPA(i,0,arr[0]) dp[0][i] = 1;
  47. REP(i,1,n)
  48. {
  49. REPA(j,0,arr[i])
  50. {
  51. REPA(k,0,513)
  52. {
  53. dp[i][k] += dp[i-1][j^k];
  54. dp[i][k] %= mod;
  55. }
  56. }
  57. }
  58.  
  59. REP(i,0,m+1) cout << dp[n-1][i] << " ";
  60. }
  61.  
  62. /*
  63. Sample input
  64.  
  65. 5 10
  66. 1 6 12 4 8
  67.  
  68. Sample output
  69.  
  70. 606 606 606 606 602 602 601 601 420 420 420
  71. */
Success #stdin #stdout 0s 4348KB
stdin
5 10
1 6 12 4 8
stdout
606 606 606 606 602 602 601 601 420 420 420