fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int L[33554432];
  6.  
  7.  
  8. int N,K,M;
  9. unsigned int MM;
  10. long long ans;
  11.  
  12.  
  13.  
  14. void GenL(int i, unsigned int Xor){
  15. if (i == N){
  16. L[ Xor% MM ]++;
  17. return;
  18. }
  19. Xor*=33;
  20. for (int Z=1;Z<=26;Z++)
  21. GenL(i+1, (Xor^Z));
  22. }
  23.  
  24. unsigned int INVERS_MOD;
  25.  
  26. void GenR(int i,unsigned int Xor){
  27. if (i)
  28. Xor*=INVERS_MOD;
  29. if (i == N){
  30. //R[ (Xor % MM) ]++;
  31. ans+=L[Xor%MM ];
  32. return;
  33. }
  34.  
  35. for (int Z=1;Z<=26;Z++)
  36. GenR(i+1, ( (Xor^Z) ) );
  37. }
  38.  
  39.  
  40.  
  41. int main(){
  42.  
  43. cin >> N >> K >> M;
  44. MM = (1ll<< M);
  45.  
  46. if (N <= 5){
  47. GenL(0,0);
  48. cout << L[K];
  49. //system("pause");
  50. return 0;
  51. }
  52.  
  53.  
  54. INVERS_MOD = 1;
  55. unsigned int pref = 32;
  56.  
  57. for (int i=5;i<M;i++){
  58. if ( (i/5) & 1)
  59. INVERS_MOD+=pref;
  60. pref*=2;
  61. }
  62.  
  63. int nn = N;
  64. N = 5;
  65. GenL(0,0);
  66. N = nn - 5;
  67. GenR(0,K);
  68.  
  69.  
  70. cout << ans;
  71. //system("pause");
  72.  
  73. }
  74.  
Success #stdin #stdout 0s 134464KB
stdin
Standard input is empty
stdout
1