fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define MAX 1000001
  4.  
  5. using namespace std;
  6.  
  7. int main ()
  8. {
  9. int k, l, m, a[52];
  10. scanf("%d %d %d", &k, &l, &m);
  11. for (int i=0; i<m; ++i)
  12. scanf("%d", &a[i]);
  13. string ans;
  14. bool dp[MAX];
  15. dp[0] = 0;
  16. dp[1] = 1;
  17. dp[k] = 1;
  18. dp[l] = 1;
  19. for (int i=2; i<k; ++i)
  20. dp[i] = !dp[i-1];
  21. for (int i=k+1; i<l; ++i)
  22. dp[i] = !(dp[i-1] & dp[i-k]);
  23. for (int i=l+1; i<MAX; ++i)
  24. dp[i] = !(dp[i-k] & dp[i-1] & dp[i-l]);
  25. for (int i=0; i<m; ++i)
  26. if (dp[a[i]]) ans += 'A';
  27. else ans += 'B';
  28. cout << ans << endl;
  29. return 0;
  30. }
Success #stdin #stdout 0s 16088KB
stdin
Standard input is empty
stdout