Advertisement
jeff69

Untitled

Apr 15th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. // ConsoleApplication209.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. //#include "stdafx.h"
  5.  
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <fstream>
  9. #include <cstring>
  10. #include <string>
  11. #include <functional>
  12. #include <cmath>
  13. #include<algorithm>
  14. typedef long long ll;
  15. using namespace std;
  16. int n, l, k;
  17. ll dp[1000004][2];
  18. // 2 3 12
  19. ll 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. b = solve(1 - x, y - l);
  37.  
  38. a = solve(1 - x, y - 1);
  39. // cout << a << ' ' << b << ' ' << c << '\n';
  40. if (a == x){
  41. ans = a;
  42. }
  43. else if (b == x){
  44. ans = b;
  45. }
  46. else{
  47. ans = c;
  48.  
  49. }
  50. dp[y][x] = ans;
  51. return ans;
  52. }
  53.  
  54. int main()
  55. {
  56. cin >> k >> l;
  57. cin >> n;
  58. int h;
  59. memset(dp, -1, sizeof dp);
  60. for (int i = 0; i < n; i++)
  61. {
  62. cin >>h;
  63.  
  64. if (solve(0, h))cout << 'B';
  65. else cout << 'A';
  66.  
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement