fork download
  1. #include <stdio.h>
  2.  
  3. using namespace std;
  4.  
  5. const int answer = {
  6.  
  7. {
  8. { 1048576 },
  9. { 524288, 0 },
  10. { 349526, 174763, 116793 },
  11. { 262144, 0, 87381, 0 },
  12. { 209716, 104858, 69906, 52429, 42025 },
  13. { 174763, 174763, 58482, 0, 34966, 58738 },
  14. { 149797, 74898, 49930, 37449, 29951, 25102, 22192 },
  15. { 131072, 131072, 43691, 0, 26215, 0, 18724, 0 },
  16. { 116509, 58254, 39143, 29127, 23272, 19494, 16416, 14564, 12740 },
  17. { 104858, 104858, 34945, 0, 22059, 34954, 14984, 0, 11676, 16370 },
  18. },
  19.  
  20. {
  21. { 2097152 },
  22. { 1048576, 0 },
  23. { 699051, 349525, 233586 },
  24. { 524288, 524288, 174762, 524288 },
  25. { 419431, 209716, 139804, 104857, 84050 },
  26. { 349526, 349526, 116793, 174763, 69908, 0 },
  27. { 299594, 149797, 99849, 74898, 59914, 49934, 42632 },
  28. { 262144, 262144, 87382, 262144, 52429, 0, 37449, 0 },
  29. { 233017, 116508, 80102, 58254, 46553, 38937, 33296, 29127, 22775 },
  30. { 209716, 209716, 69840, 0, 41820, 0, 29956, 0, 23316, 0 },
  31. },
  32.  
  33. {
  34. { 4194304 },
  35. { 2097152, 2097152 },
  36. { 1398102, 699051, 466489 },
  37. { 1048576, 1048576, 349526, 1048576 },
  38. { 838861, 419430, 279622, 209716, 167076 },
  39. { 699051, 0, 240306, 0, 139808, 232903 },
  40. { 599187, 299594, 199731, 149797, 120066, 99869, 86580 },
  41. { 524288, 0, 174762, 0, 104857, 0, 74898, 0 },
  42. { 466034, 233017, 155505, 116509, 93266, 77669, 66592, 58254, 45500 },
  43. { 419431, 419431, 139811, 0, 88506, 139812, 59918, 0, 46603, 85228 },
  44. },
  45.  
  46. {
  47. { 8388608 },
  48. { 4194304, 4194304 },
  49. { 2796203, 1398102, 930930 },
  50. { 2097152, 0, 699051, 0 },
  51. { 1677722, 838861, 559072, 419431, 335790 },
  52. { 1398102, 1398102, 465124, 699051, 279629, 465465 },
  53. { 1198373, 599187, 399475, 299594, 239673, 199693, 171185 },
  54. { 1048576, 1048576, 349526, 0, 209715, 0, 149797, 0 },
  55. { 932068, 466034, 313121, 233017, 186404, 155268, 133184, 116508, 102830 },
  56. { 838861, 0, 279656, 0, 163850, 0, 119499, 0, 93210, 167895 },
  57. },
  58.  
  59. {
  60. { 16777216 },
  61. { 8388608, 0 },
  62. { 5592406, 2796203, 1861860 },
  63. { 4194304, 4194304, 1398101, 0 },
  64. { 3355444, 1677722, 1118482, 838861, 668508 },
  65. { 2796203, 0, 928370, 0, 559261, 0 },
  66. { 2396746, 1198373, 799188, 599186, 479894, 399450, 342225 },
  67. { 2097152, 2097152, 699051, 2097152, 419430, 0, 299594, 0 },
  68. { 1864136, 932068, 620564, 466034, 372796, 311336, 266334, 233017, 207480 },
  69. { 1677722, 1677722, 559246, 838861, 336200, 0, 239664, 0, 186430, 335790 },
  70. },
  71.  
  72. {
  73. { 33554432 },
  74. { 16777216, 0 },
  75. { 11184811, 5592405, 3726450 },
  76. { 8388608, 0, 2796203, 8388608 },
  77. { 6710887, 3355443, 2236492, 1677722, 1339066 },
  78. { 5592406, 0, 1865273, 0, 1118482, 1865273 },
  79. { 4793491, 2396745, 1597835, 1198373, 958656, 798926, 683134 },
  80. { 4194304, 0, 1398102, 0, 838861, 0, 599186, 0 },
  81. { 3728271, 1864135, 1243513, 932068, 745665, 621758, 532549, 466034, 415416 },
  82. { 3355444, 3355444, 1118482, 0, 669940, 0, 479363, 0, 372825, 671580 },
  83. },
  84.  
  85. {
  86. { 67108864 },
  87. { 33554432, 33554432 },
  88. { 22369622, 11184811, 7427385 },
  89. { 16777216, 0, 5592406, 0 },
  90. { 13421773, 6710887, 4473913, 3355443, 2936024 },
  91. { 11184811, 11184811, 3727815, 5592406, 2236960, 0 },
  92. { 9586981, 4793491, 3195662, 2396746, 1917835, 1597852, 1369485 },
  93. { 8388608, 0, 2796202, 0, 1677721, 2796202, 1198372, 0 },
  94. { 7456541, 3728271, 2504936, 1864135, 1491308, 1241467, 1065216, 932068, 826507 },
  95. { 6710887, 0, 2236960, 0, 1258284, 0, 960915, 0, 745654, 1339884 },
  96. },
  97.  
  98. {
  99. { 134217728 },
  100. { 67108864, 0 },
  101. { 44739243, 22369622, 14908530 },
  102. { 33554432, 33554432, 11184811, 0 },
  103. { 26843546, 13421773, 8947821, 6710887, 5348064 },
  104. { 22369622, 0, 7460409, 0, 4473881, 0 },
  105. { 19173962, 9586981, 6391332, 4793490, 3834790, 3195662, 2752575 },
  106. { 16777216, 16777216, 5592406, 0, 3355443, 0, 2396745, 0 },
  107. { 14913081, 7456541, 4973646, 3728270, 2982809, 2490326, 2130136, 1864135, 1638000 },
  108. { 13421773, 13421773, 4473923, 6710886, 2683028, 4473913, 1917385, 3355443, 1491305, 2687960 },
  109. },
  110.  
  111. {
  112. { 268435456 },
  113. { 134217728, 0 },
  114. { 89478486, 44739243, 29830713 },
  115. { 67108864, 0, 22369621, 67108864 },
  116. { 53687092, 26843546, 17895696, 13421773, 10748560 },
  117. { 44739243, 0, 14920818, 22369621, 8947852, 14898290 },
  118. { 38347923, 19173962, 12782639, 9586981, 7669783, 6391316, 5448684 },
  119. { 33554432, 33554432, 11184811, 0, 6710886, 11184811, 4793490, 0 },
  120. { 29826162, 14913081, 9943572, 7456540, 5965699, 4971330, 4248744, 3728270, 3316040 },
  121. { 26843546, 26843546, 8947280, 0, 5347860, 8947849, 3834663, 0, 2982618, 5366907 },
  122. },
  123.  
  124. {
  125. { 536870912 },
  126. { 268435456, 0 },
  127. { 178956971, 89478485, 59650503 },
  128. { 134217728, 134217728, 44739242, 0 },
  129. { 107374183, 53687091, 35791264, 26843545, 21391848 },
  130. { 89478486, 89478486, 29833444, 44739243, 17895670, 29709540 },
  131. { 76695845, 38347923, 25566082, 19173961, 15339233, 12782642, 10960562 },
  132. { 67108864, 67108864, 22369621, 0, 13421773, 0, 9586980, 0 },
  133. { 59652324, 29826162, 19806416, 14913081, 11930857, 9946754, 8521742, 7456541, 6599320 },
  134. { 53687092, 53687092, 17895696, 0, 10742006, 0, 7669573, 13421773, 5965249, 10743645 },
  135. },
  136.  
  137. };
  138.  
  139.  
  140. int main() {
  141. int k, n, m, x, temp;
  142. int answer = 0;
  143. scanf("%d%d%d%d", &k, &n, &m, &x);
  144. int max = 1 << k;
  145. if (n < m) {
  146. temp = n;
  147. n = m;
  148. m = temp;
  149. }
  150. if (k >= 20 && n <= 10) {
  151. printf("%d", answer[k - 20][n - 1][m - 1]);
  152. return 0;
  153. }
  154. for (int i = 0; i < max; i += n)
  155. if ((x ^ i) % m == 0)
  156. ++answer;
  157. printf("%d\n", answer);
  158. }
Success #stdin #stdout #stderr 0.29s 40412KB
stdin
30 4 2 15
stdout
Standard output is empty
stderr
Error: unexpected symbol in "using namespace"
Execution halted