题目:内阁会议

代码:

#define endl '\n'
using namespace std;
int n;
bool isPrime(int x){
	if(x<2)return false;
	for(int i=2;i*i<=x;++i){
		
	}
}
bool check(string s,string pre) {
	if(s==pre)
		return false;
	if(s[0]=='0')
		return false;
	if(!isPrime(tonum(s)))
		return false;
	return true;
}
void bfs(string s,string t) {
	struct stu{string pre,int step};
	queue<stu> que;
	que.push((stu){s,0});
	while(!que.empty()) {
		stu fr=que.front();
		que.pop();
		if(fr.pre==t) {
			cout<<fr.step;
			return;
		}
		for(int i=0;i<4;++i){
			for(int j=0; j<=9;++j) {
				string ns=fr.pre;
				ns[i]=j+'0';
				if(check(ns,fr.pre)) {
					que.push((stu) {ns,fr.step+1});
					a[nx][ny]=true;
				}
			}	
		}
		
	}
}
int main() {

	cin>>n;
	while(n--){
		string s,t;
		cin>>s>>t;
		bfs(s,t);
	}


	return 0;
}