Advertisement
jeff69

Untitled

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