light oj 1005 不知道是个什么玩意

A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move vertically or horizontally from its current position and two rooks attack each other if one is on the path of the other. In the following figure, the dark squares represent the reachable locations for rook R1 from its current position. The figure also shows that the rook R1 and R2 are in attacking positions where R1 and R3 are not. R2 and R3 are also in non-attacking positions.

Now, given two numbers n and k, your job is to determine the number of ways one can put k rooks on an n x n chessboard so that no two of them are in attacking positions.

Input
Input starts with an integer T (≤ 350), denoting the number of test cases.

Each case contains two integers n (1 ≤ n ≤ 30) and k (0 ≤ k ≤ n2).

Output
For each case, print the case number and total number of ways one can put the given number of rooks on a chessboard of the given size so that no two of them are in attacking positions. You may safely assume that this number will be less than 1017.

Sample Input
Output for Sample Input
8
1 1
2 1
3 1
4 1
4 2
4 3
4 4
4 5
Case 1: 1
Case 2: 4
Case 3: 9
Case 4: 16
Case 5: 72
Case 6: 96
Case 7: 24
Case 8: 0

这题我真的不知道是个什么…
也许是个数学题
但是归类非说是DP…
鬼知道是什么玩意
反正状态转移一晚上没找到….
GTMDDP!!

思路是这样的…
你第一个可以随便选…
有n^2个..第二次就只有(n-1)^2个了…
以此类推…..
但是你这个第一个和第X个也许…会放重复
但你多算了…
因此除以k的全排列就可以….

这怎么可能是DP.嗯?!!
这怎么转移?!!

#include <iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<memory.h>
using namespace std;
long long x[31];
int biaoji[31];
int main()
{
    for(int a=1;a<=30;a++)x[a]=a*a;
    int T;
    cin>>T;
    int u=0;
    while(T--)
    {
        int n,k;
        cin>>n>>k;
        if(k>n)
        {
            printf("Case %d: 0\n",++u);
            continue;
        }
        long long sum=1;
        memset(biaoji,0,sizeof(biaoji));
        for(int a=n-k+1;a<=n;a++)
        {
            sum*=x[a];
            for(int b=1;b<=k;b++)
            {
                if(biaoji[b]==0)
                {
                    if(sum%b==0)
                    {
                        biaoji[b]=1;
                        sum/=b;
                    }
                }
            }
        }
        printf("Case %d: %lld\n",++u,sum);
    }
    return 0;
}
core-oj.jar是一个用于在线评测系统的核心文件。在线评测系统是为了方便对编程作业进行自动化评测而开发的系统。它主要提供了编程语言的编译及执行环境,能够接收用户提交的代码,并执行测试用例进行输出结果的比对。 core-oj.jar是这个在线评测系统的核心库文件,它包含了评测系统运行所需的各种功能模块。 首先,core-oj.jar包含了编程语言的编译器。它能够将用户提交的代码进行编译,生成可执行文件或者字节码,以便后续的运行和评测。 其次,core-oj.jar提供了丰富的执行环境。它能够创建并管理多个运行环境,每个环境可以运行一个用户提交的代码。这些环境可以在独立的进程中运行,避免了代码之间的相互影响。 此外,core-oj.jar还提供了用于输入输出重定向的功能。它能够将用户代码中的输入输出连接到指定的输入输出流,以便比对用户代码的输出和预期输出是否一致。 最后,core-oj.jar还提供了一些用于评测和判题的辅助函数。它们可以根据定义的评测规则,对用户代码的输出结果进行比对,并给出相应的评测结果。 总而言之,core-oj.jar是一个在线评测系统中的核心文件,通过它提供的各种功能,可以实现对编程作业的自动化评测。它起到了连接用户提交的代码和评判系统之间的桥梁作用,提供了安全、高效和准确的评测环境,帮助学生更好地完成编程任务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值