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