The Nerd Factor SPOJ - MYQ5
Time Limit: 1000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description
Prof.Venky handles Advanced Topics in Algorithms course for a class of 'n' students. He is always known for his unsolvable question papers. Knowing that it is impossible to pass his subject in a fair manner, one of the students of his class, Vishy, finds out from his seniors that Prof.Venky won't be able to find out if at least 'k' students together discuss and write the answers and thereby all of them can pass. Hence they decide to divide the whole class into a number of groups so that everyone passes. But all the students are fighting over forming the groups. So Puppala, one of the nerdy students in the class, decides that he will compute all possible ways that they can form the groups and number them, and finally choose one of those numbers at random and go ahead with that way. Now it is your duty to help Puppala find the number of ways that they can form such groups.
Pupalla is incapable of reading big numbers, so please tell him the answer modulo 10^9+7.
Input
The first line contains the number of test case t(1<=t<=10^6).
Followed by t lines for each case.
Each test case contains two integers 'n' and 'k' separated by a space(1<=k,n<=1000)
Output
For each test case, print a single line containing one positive integer representing the number of ways modulo 10^9+7 .
Example
Input: 3
2 1
4 2
6 2 Output: 2
2
4
#include <iostream>
#include <stdio.h>
using namespace std;
#define mod 1000000007
int dp[][]={};
void init()
{
int i,j;
for(i=;i<=;i++)dp[i][i]=;
for(i=;i<=;i++)
{
for(j=i-;j>;j--)dp[i][j]=(dp[i][j+]+dp[i-j][j])%mod;
}
}
int main()
{
init();
int t,n,k;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
printf("%d\n",dp[n][k]);
}
return ;
}
The Nerd Factor SPOJ - MYQ5的更多相关文章
- 【SPOJ】1812. Longest Common Substring II(后缀自动机)
http://www.spoj.com/problems/LCS2/ 发现了我原来对sam的理解的一个坑233 本题容易看出就是将所有匹配长度记录在状态上然后取min后再对所有状态取max. 但是不要 ...
- SPOJ Lexicographical Substring Search 后缀自动机
给你一个字符串,然后询问它第k小的factor,坑的地方在于spoj实在是太慢了,要加各种常数优化,字符集如果不压缩一下必t.. #pragma warning(disable:4996) #incl ...
- 【刷题】SPOJ 1811 LCS - Longest Common Substring
A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the s ...
- SPOJ 1812 Longest Common Substring II(后缀自动机)(LCS2)
A string is finite sequence of characters over a non-empty finite set Σ. In this problem, Σ is the s ...
- BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]
2588: Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 5217 Solved: 1233 ...
- SPOJ DQUERY D-query(主席树)
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- SPOJ LCS2 - Longest Common Substring II
LCS2 - Longest Common Substring II A string is finite sequence of characters over a non-empty finite ...
- Leetcode 254. Factor Combinations
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a func ...
随机推荐
- C#/VB.NET对EXCEL图片添加超链接
在日常工作中,在编辑文档时,为了方便自己或者Boss能够实时查看到需要的网页或者文档是,需要对在Excel中输入的相关文字进行超链接,那么对于一些在Excel中插入的图片我们该怎么实现超链接呢,下面给 ...
- 【JCP模式实战--ferrous-framework】ferrous前端开发框架邀您初体验
一.简介 ferrous-framework是为了迎合微服务架构而封装的纯前端开发框架. 实现了一种介于单页面和多页面的开发模式,让大家根据自己的需要对单页面和多页面进行切换或者共存. 页面结构采用J ...
- 微信中通过页面(H5)直接打开本地app的解决方案
简述 微信中通过页面直接打开app分为安卓版和IOS版,两个的实现方式是完全不同的. 安卓版实现:使用腾讯的应用宝,只要配置了“微下载”之后,打开链接腾讯会帮你判断本地是否已经安装了app,如果本地安 ...
- 使用CXF开发JAX-RS类型的WebService
1.JAXRSServerFactoryBean编程方式 访问方式:http://localhost:8080/cxf_spring_rest_server/ws/rest/student/query ...
- docker学习之--日常命令
.查看镜像 sudo docker images sudo pull docker.io #下载镜像 sudo push docker.io #上传镜像 sudo docker save -o cen ...
- Swing-JSlider用法-入门
JSlider是Swing中的滑块控件,在交互过程中用户可拖动它来实现数值的调整.它具有3个基本参数,分别为:最小值.最大值和初始值,如果不指定数值,则默认值分别为:0,100,50.滑块的值发生改变 ...
- 201521123012 《Java程序设计》第一周学习总结
一.本章学习内容 1.了解了JDK.JRE .JVM. 2.大概看过了Java的诞生.版本演进(JDK1.1.4,JDK1.1.5--JDK1.1.8,J2SE1.2--Java SE 8)以及三大平 ...
- 201521123113《Java程序设计》第11周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2. 书面作业 本次PTA作业题集多线程 Q1.互斥访问与同步访问 完成题集4-4(互斥访问)与4-5(同步访问) ...
- 第一部分----HTML的基本结构与基本标签
PART-1 HTML的基本结构以及Header的部分 一.什么是HTML? HTML是超文本标签语言,即网页的源码.而浏览器就是翻译解释HTML源码的工具. 二.HTML文档的结构: 三.详细注释 ...
- Windows下用Composer安装Laravel步骤(集成php环境用phpStudy2016版本)
描述:到官方网站了解并根据自己所需要的版本号安装,所需要的php版本是多少. 中文网站:http://www.golaravel.com/ 官方网站:https://laravel.com/ 其实各自 ...