fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // Speed
  5. #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  6.  
  7. // Typedefs
  8. #define int long long
  9. #define pb push_back
  10. #define ff first
  11. #define ss second
  12. #define all(x) (x).begin(), (x).end()
  13. #define rall(x) (x).rbegin(), (x).rend()
  14. #define sz(x) ((int)(x).size())
  15. #define endl '\n'
  16. #define yes cout << "yes\n"
  17. #define no cout << "no\n"
  18.  
  19. // Loops
  20. #define rep(i,a,b) for(int i=a;i<b;++i)
  21. #define per(i,a,b) for(int i=b-1;i>=a;--i)
  22. #define each(x, a) for (auto& x : a)
  23.  
  24. // Consts
  25. const int INF = 1e18;
  26. const int MOD = 1e9+7;
  27. const int N = 2e5 + 5;
  28.  
  29. // Math
  30. int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
  31. int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
  32.  
  33. int power(int a, int b, int m = MOD) {
  34. int res = 1;
  35. while (b > 0) {
  36. if (b & 1) res = res * a % m;
  37. a = a * a % m;
  38. b >>= 1;
  39. }
  40. return res;
  41. }
  42.  
  43. int modinv(int a, int m = MOD) {
  44. return power(a, m - 2, m);
  45. }
  46.  
  47. vector<int> getPerm(int idx) {
  48. vector<int> a = {1,2,3,4};
  49. for (int i = 1; i < idx; i++)
  50. next_permutation(a.begin(), a.end());
  51. return a;
  52. }
  53.  
  54. void comparePerm(int j, int k) {
  55. vector<int> p = getPerm(j);
  56. vector<int> q = getPerm(k);
  57.  
  58. int A = 0, B = 0;
  59. vector<int> usedP(4, 0), usedQ(4, 0);
  60.  
  61. for (int i = 0; i < 4; i++) {
  62. if (p[i] == q[i]) {
  63. A++;
  64. usedP[i] = usedQ[i] = 1;
  65. }
  66. }
  67.  
  68. for (int i = 0; i < 4; i++) {
  69. if (usedP[i]) continue;
  70. for (int t = 0; t < 4; t++) {
  71. if (!usedQ[t] && p[i] == q[t]) {
  72. B++;
  73. usedQ[t] = 1;
  74. break;
  75. }
  76. }
  77. }
  78.  
  79. cout << A << "A" << B << "B" << endl;
  80. }
  81.  
  82. // Logic
  83. void solve() {
  84. // Code
  85. int j, k;
  86. cin >> j >> k;
  87.  
  88. j = (j - 1) % 24 + 1;
  89. k = (k - 1) % 24 + 1;
  90.  
  91. comparePerm(j, k);
  92. }
  93.  
  94. // Main
  95. int32_t main() {
  96. fast_io;
  97.  
  98. int t;
  99. cin >> t;
  100. while (t--) {
  101. solve();
  102. }
  103.  
  104. return 0;
  105. }
  106.  
Success #stdin #stdout 0.01s 5284KB
stdin
3
1234 15 9
1234 1 24
1234 1 1
stdout
0A4B
2A2B
0A4B