A group of contest writers have written n problems and want to use k of them in an upcoming contest. Each problem has a difficulty level. A contest is valid if all of its k problems have different difficulty levels.

Compute how many distinct valid contests the contest writers can produce. Two contests are distinct if and only if there exists some problem present in one contest but not present in the other.

Print the result modulo 998,244,353.

Input

The first line of input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 1000)

The next line contains n space-separated integers representing the difficulty levels. The difficulty levels are between 1 and 109 (inclusive).

Output

Print the number of distinct contests possible, modulo 998,244,353.

Sample Input

5 2

1 2 3 4 5

Sample  Output

10

题意:

选出k个难度不同的题,问有几种选法。

思路:

dp[i][j]表示从i种不同的题中选出j个不同的题的方法数。

当前题选的话,方法数是dp[i-1][j-1]*(当前难度题的个数)

当前题不选的话,方法数是dp[i-1][j].

dp[i][j]就是二者之和。

#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#define fuck(x) cout<<#x<<" = "<<x<<endl;
#define ls (t<<1)
#define rs ((t<<1)+1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = ;
const int inf = 2.1e9;
const ll Inf = ;
const int mod = ;
const double eps = 1e-;
map<int,int>mp;
ll dp[][];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
ll ans=;
ll num=;
for(int i=;i<=n;i++){
int x;
scanf("%d",&x);
mp[x]++;
}
map<int,int>::iterator it=mp.begin();
int sz=mp.size();
for(int i=;i<=sz;i++){
dp[i][]=;
}
for(int i=;i<=sz;i++){
for(int j=k;j>=;j--){
dp[i][j]=dp[i-][j]+dp[i-][j-]*(it->second);
dp[i][j]%=mod;
}
it++;
}
printf("%lld\n",dp[sz][k]); }

Gym - 101982C Contest Setting (动态规划)的更多相关文章

  1. Contest Setting 2018 ICPC Pacific Northwest Regional Contest dp

    题目:https://vj.69fa.cn/12703be72f729288b4cced17e2501850?v=1552995458 dp这个题目网上说是dp+离散化这个题目要对这些数字先处理然后进 ...

  2. 2018-2019 ACM-ICPC Pacific Northwest Regional Contest C Contest Setting(DP)

    比赛链接:Contest Setting C题 题意:$n$道题目,每道题目难度为$ai$,选择$k$道难度不同的题目,有多少种选择方案.$1<=k<=n<=1000,1<=a ...

  3. C - Contest Setting Gym - 101982C dp 补题

    题目链接:https://vjudge.net/contest/273260#problem/C 学习了一下别人的思路,首先去重,然后离散化. dp数组开二维,每一次更新,状态转移方程,dp[ i ] ...

  4. 2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1)

    2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) 思路: A Exam 思路:水题 代码: #include<bits ...

  5. 2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) Solution

    A:Exam Solved. 温暖的签. #include<bits/stdc++.h> using namespace std; ; int k; char str1[maxn], st ...

  6. HDUOJ-----I NEED A OFFER!

    I NEED A OFFER! Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Tot ...

  7. Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】

    F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standar ...

  8. Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】

    E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...

  9. 2019春季训练02: JU Flash Contest Gym - 102035 训练报告与复盘

    这场题极其简单 Solved 19 / 19 A Gym 102035A N integers 略 Solved 10 / 33 B Gym 102035B Mahmoud the Thief 用ma ...

随机推荐

  1. 服务器三:多线程epoll

    #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <ar ...

  2. adb 查看 android手机的CPU架构

    adb shell cat  /proc/cpuinfo 当然要下载adb并配置好环境变量

  3. Android项目实战登录&注册

    由于项目中大部分界面都有一个后退键和一个标题栏,为避免代码冗杂以及便于利用,我们可以将后推荐和标题栏单独抽取出来定义一个标题栏布局,在 res/layout 目录下新建一个 Layout resour ...

  4. Android项目实战欢迎界面

    欢迎界面 首先同理把欢迎界面的图片导入到drawable目录下,在导入时 Android Studio 会提示如下 drawable 具体本人尚未弄明白,待理解后会重新补全本部分内容,在此本人选了第一 ...

  5. 智能ERP收银统计-优惠统计计算规则

    1.报表统计->收银统计->优惠统计规则          第三方平台优惠:(堂食订单:支付宝口碑券优惠)+(外卖订单:商家承担优惠)          自平台优惠:(堂食订单:商家后台优 ...

  6. MyDAL - .IsExistAsync() 使用

    索引: 目录索引 一.API 列表 .IsExistAsync() 用于 单表 / 多表连接 查询 二.API 单表-便捷 方法 举例 1.单表-便捷, 判断是否存在方法 var date = Dat ...

  7. HTML基础-------HTML标签(2)

    HTML标签(2) a标签(容器级单标签) 语义:跳转到指定的连接 属性 列表系列 1.无序列表 该列表由两部分组成:ul标签嵌套li标签(ul标签是典型的容器级标签) 图示: 2.有序列表 该列表由 ...

  8. WEB 性能测试用例设计以及总结

    WEB 性能测试用例设计以及总结 WEB 性能测试用例设计模型是设计性能测试用例的一个框架,在实际项目中,需要对其进行适当的剪裁,从而确定性能测试用例的范围和类别.剪裁的依据是性能测试策略和测试范围, ...

  9. arts打卡 从排序数组中删除重复项

    Algorithm 从排序数组中删除重复项     给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度. 不要使用额外的数组空间,你必须在原地修改输入数组 ...

  10. Codeforces Goodbye 2018

    Goodbye 2018 可能是我太菜考试的时候出不了$E$ 可能是我太菜考试的时候调不出$F$ 所以转化为手速场之后手速还上不去.jpg A 模拟题意... #include <cstdio& ...