Advertisement
jeff69

Untitled

Apr 15th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <fstream>
  5. #include <cstring>
  6. #include <string>
  7. #include <functional>
  8. #include <cmath>
  9. #include<algorithm>
  10. typedef long long ll;
  11. using namespace std;
  12. int a[35], n, l, k;
  13. ll dp[1000004][2];
  14. // 2 3 12
  15. int x;
  16. ll solve( ll y){
  17. if (y < 0){
  18.  
  19. return x;
  20.  
  21. }
  22. if (y == 0){
  23. return 1 - x;
  24.  
  25.  
  26. }
  27. if (dp[y][x] != -1)return dp[y][x];
  28. int ans = 1 - x;
  29. int a, b, c;
  30. x = 1 - x;
  31. c = solve( y - k);
  32. x = 1 - x;
  33. x = 1 - x;
  34. b = solve( y - l);
  35. x = 1 - x;
  36. x = 1 - x;
  37.  
  38. a = solve(y - 1);
  39. x = 1 - x;
  40. //cout << a << ' ' << b << ' ' << c << '\n';
  41. if (a == x ){
  42. ans = a;
  43. }
  44. else if (b == x ){
  45. ans= b;
  46. }
  47. else{ ans= c;
  48.  
  49. }
  50. dp[y][x] = ans;
  51. return ans;
  52. }
  53.  
  54. int main()
  55. {
  56. cin >> k >> l;
  57. if (k > l){
  58. swap(k, l);
  59. }
  60. cin >> n;
  61. for (int i = 0; i < n; i++)
  62. {
  63. cin >> a[i];
  64.  
  65. memset(dp, -1, sizeof dp);
  66. x = 0;
  67. if (solve(a[i]))cout << 'B';
  68. else cout << 'A';
  69.  
  70. }
  71.  
  72.  
  73.  
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement