51nod 1995 三子棋 思维打表

题目:http://www.51nod.com/Challenge/Problem.html#!#problemId=1995

题解:

以下几个格子,是存在对称的,字母相同的其实可以看作同一种下法。所以只考虑左上角的四个就好。其中A位置想要赢最少6步,B和D最少4步,C只会平局

然后是对这ABCD 这4种情况打表;

#include <iostream>

using namespace std;

int main() {

    int ans[3][4] = {6, 4, 4, 6, 
                     0, 4, 4, 0,
                     6, 4, 4, 6};
    int t;
    int x, y;

    cin >> t;
    while (t > 0) {
        t--;
        cin >> x >> y;
        x--;y--;
        if (x == 1 &&(y == 0 || y == 3)) {
                cout << "Equal\n"<<0<<endl;
                continue;
        }
        cout << "Win\n" << ans[x][y] << endl;
    }
    return 0;
}

 

思路来源:https://blog.csdn.net/hester_hester/article/details/86438117 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值