Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

Problemset: Bakushin's Genius Game

Language: cpp

Time: 0.011 second

Submitted On: 2026-11-07 11:28:24

#include <bits/stdc++.h>
using namespace std;

int sol(int n){ // find the max div for n
	if (n<2 || n%2==1) return -1;
	for (int i=2;i<=sqrt(n);i+=2){
		if (n%i==0) return i;
	}
	return -1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int k; cin >> k;
    while(k--){
       int n; cin >> n;

       bool who = false;
       while(n!=0){
            int save = sol(n);

                if(save == -1) n--;
                else n = save;

            who = !who;
       }

       if(!who) cout << 'B' << '\n';
       else cout << 'A' << '\n';
    }
}