Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <functional>
- #include <algorithm>
- #include <math.h>
- #include <cmath>
- #include <string>
- #include <cstring>
- #include <vector>
- #include<set>
- #include<map>
- #include <time.h>
- #include <fstream>
- typedef long long ll;
- using namespace std;
- int n, l, k;
- int dp[1000004][2];
- // 2 3 12
- int solve(int x, int y){
- if (y < 0){
- return x;
- }
- if (y == 0){
- return 1 - x;
- }
- if (dp[y][x] != -1)return dp[y][x];
- if (dp[y][1-x] != -1)return 1-dp[y][1-x];
- int ans = 1 - x;
- int a, b, c;
- c = solve(1 - x, y - k);
- cout << c << '\n';
- b = solve(1 - x, y - l);
- a = solve(1 - x, y - 1);
- // cout << a << ' ' << b << ' ' << c << '\n';
- if (a == x){
- ans = a;
- }
- else if (b == x){
- ans = b;
- }
- else{
- ans = c;
- }
- dp[y][x] = ans;
- return ans;
- }
- int main()
- {
- cin >> k >> l;
- cin >> n;
- int h;
- for (int i = 0; i < 1000004; i++){
- dp[i][0] = -1;
- dp[i][1] = -1;
- }solve(0, 1000000);
- for (int i = 0; i < n; i++)
- {
- cin >>h;
- if (solve(0, h))cout << 'B';
- else cout << 'A';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement