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. es6之字符串添加的东西

    在es6里边对字符串添加了一些东西! 字符串模板(非常友善) 相信大家之前都遇到过万恶的字符串拼接,真是噩梦,不过之后有了字符串模板之后,再也不用担心字符串拼接会乱了... 之前的字符串拼接 let ...

  2. sql 服务启动失败 SQL Server(MSSQLSERVER) 错误码126

    SQL配置管理器-->sql server 网络配置-->mssqlerver的协议-->VIA禁用服务

  3. jQuery元素操作

    jQuery中创建元素及追加元素 DOM中可以动态创建元素:document.createElement(“标签的名字”); jQuery中同样可以创建元素标签,并且返回的就是jQuery对象,可以直 ...

  4. dotnet core如何编译exe

    dotnet core 有一个转变,他用dll格式来代替exe作为通用执行格式,然后要命令行dotnet yourApp.dll 来运行程序.为了提高逼格,双击可以运行,可以采用以下方案: 方案一 用 ...

  5. 一分钟了解Allegro导入DXF文件

    Allegro, pads,PCB线路板设计,小北PCB 很高兴与大家分享一分钟了解Allegro导入DXF文件的方法,请问您们,刚学习这个软件时,您是否遇到过同样的问题呢?应该我们每一个刚学习者都会 ...

  6. Python之函数参数

    # -*- coding: utf-8 -*- """ Created on Fri Sep 7 09:13:50 2018 @author: zhen "&q ...

  7. 如何自己制作CHM电子书?

    软件介绍: EasyCHM 非常适合个人和单位制作高压缩比的有目录.索引,同时具有全文检索及高亮显示搜索结果的网页集锦.CHM格式的帮助文件.专业的产品说明书.公司介绍.文章集锦.CHM电子书等等. ...

  8. Docker之初识(一)

    1.简介 今年四月份公司逐步改用docker容器来部署应用,当时自己刚踏出学校大门,平时开发都是环境都是早已安装好,因此一直没怎么了解Docker这玩意.公司里各位开发大佬说这是个好东西,可以很方便的 ...

  9. 【心得】Lattice Diamond 后端约束实战小结

    [博客导航] [导航]FPGA相关 IOB约束 参考<插入IO寄存器和位置约束---lattice&diamond>,推荐的方法是: 1.在strategy设置[Map Desig ...

  10. uWSGI、WSGI、uwsgi是什么?

    uWSGI是一个web服务器,它实现了WSGI协议.uwsgi协议.HTTP等协议: WSGI是web服务器网管接口,是一套协议,用于接收用户请求并将请求进行初次封装,然后交给web框架: uwsgi ...