Example #1
0
QPoint Reversi::ai(const int player)
{
	const int choices[8][8] = {
		{100,	-100,	50,	30,	30,	50,	-100,	100,},
		{-100,	-100,	-50,	-50,	-50,	-50,	-100,	-100,},
		{50,	-50,	10,	10,	10,	10,	-50,	50,},
		{30,	-50,	10,	0,	0,	10,	-50,	30,},
		{30,	-50,	10,	0,	0,	10,	-50,	30,},
		{50,	-50,	10,	10,	10,	10,	-50,	50,},
		{-100,	-100,	-50,	-50,	-50,	-50,	-100,	-100,},
		{100,	-100,	50,	30,	30,	50,	-100,	100,},
	};
	QPointArray spaces = availableSpaces(player);
	if (spaces.size() == 0)
		return BoardGame::ai(player);
	int values[spaces.size()];
	for (unsigned int i = 0; i < spaces.size(); i++) {
		QPoint p(spaces[i]);
		values[i] = choices[p.y()][p.x()] + reversible(p, player) * 5;
	}
	int max = 0;
	for (unsigned int i = 0; i < spaces.size(); i++)
		if (values[i] > values[max])
			max = i;
	QList<int> equals;
	equals.setAutoDelete(true);
	for (unsigned int i = 0; i < spaces.size(); i++)
		if (values[i] == values[max])
			equals.append(new int(i));
	return spaces[*equals.at(rand() % equals.count())];
}
Example #2
0
int main(){
	int n;
    int ac;
	while(1){
		scanf("%d",&n);
		if(n<0)
			break;
		scanf("%d",&d);
		ac=0;
		int t=1;
		int origin;
		origin=n;
		while(n!=0){
			ac+=(n%10)*t;
			t*=d;
			n/=10;
		}
		//printf("a:%d\nra:%d\n",a,reversible(a));
		if(prime(origin)&&prime(reversible(origin)))
			printf("Yes\n");
		else
			printf("No\n");



	}
	return 0;
}
Example #3
0
int main(void)
{
	int i, rev = 0;

	for (i = 0; i < 1e9; ++i)
		rev += reversible(i);

	printf("%d\n", rev);
	return 0;
}
Example #4
0
int main() {
    unsigned long long i;
    unsigned long long int cnt = 0;
    char a[ 20 ];
    char b[ 20 ];

    for ( i = 12; i < MAX_N; ++i ) {
        if ( i % 10 == 0 ) {
            continue;
        }
        if ( reversible( i ) ) {
            ++cnt;
        }
        if ( i % 100000 == 1 ) {
            printf( "\rSearching %2.0f%%", 100 * ( float )i / MAX_N );
        }
    }

    printf( "There are %i reversible numbers below %i.\n", cnt, MAX_N );

    return 0;
}
Example #5
0
int main(void){
	printf("%u \n" , num_digits(0ul));
	printf("%lu \n" , reverse(12ul));
	printf("%lu \n", reversible(1000000ul));
}