• CODEVS 2451 互不侵犯


    2451 互不侵犯

    题目描述 Description

         在N×N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案。国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子。

    输入描述 Input Description

    只有一行,包含两个数N,K ( 1 <=N <=9,  0 <= K <= N * N)

    输出描述 Output Description

          方案数。

    样例输入 Sample Input

    3 2

    样例输出 Sample Output

    16

    数据范围及提示 Data Size & Hint

    1 <=N <=9,  0 <= K <= N * N

    /*bfs搜索记录数据 打表 正解dp状态压缩 蒟蒻不懂*/
    #include<cstdio>
    #include<iostream>
    using namespace std;
    long long a[10][82]={{0LL},
                    {1LL,1LL},
                    {1LL,4LL},
                    {1LL,9LL,16LL,8LL,1LL},
                    {1LL,16LL,78LL,140LL,79LL},
                    {1LL,25LL,228LL,964LL,1987LL,1974LL,978LL,242LL,27LL,1LL},
                    {1LL,36LL,520LL,3920LL,16834LL,42368LL,62266LL,51504LL,21792LL,3600LL},
                    {1LL,49LL,1020LL,11860LL,85275LL,397014LL,1220298LL,2484382LL,3324193LL,2882737LL,1601292LL,569818LL,129657LL,18389LL,1520LL,64LL,1LL},
                    {1LL,64LL,1806LL,29708LL,317471LL,2326320LL,12033330LL,44601420LL,119138166LL,229095676LL,314949564LL,305560392LL,204883338LL,91802548LL,25952226LL,4142000LL,281571LL},
                    {1LL,81LL,2968LL,65240LL,962089LL,10087628LL,77784658LL,450193818LL,1979541332LL,6655170642LL,12848094442LL,29492596820LL,46439242830LL,57647295377LL,49138545860LL,31122500764LL,14518795348LL,4959383037LL,1237072414LL,224463798LL,29275410LL,2673322LL,163088LL,6150LL,125LL,1}};
    int main()
    {
        int n,k;
        cin>>n>>k;
        cout<<a[n][k];
        return 0;
    }
  • 相关阅读:
    【jQuery Case Study 1】Site:cssninjas.com
    PostgreSQL HA双机热备份配置
    PogreSQL物理备份与逻辑备份
    转:truncate,delete和drop删除表的异同
    pgsequence序列的用例
    Linux下端口占用的解决方法
    Linux下脚本的编写和执行
    schema模式的选用
    pg数据库基础备份的注意事项
    PostgreSQL VMCC多版本并发控制
  • 原文地址:https://www.cnblogs.com/xiaoqi7/p/5876441.html
Copyright © 2020-2023  润新知