HUNNU--湖师大--11409--Skill
Skill
Yasser is an Egyptian coach; he will be organizing a training camp in Jordan. At the end of camp,
Yasser was quiet amazed that the participants solved all of the hard problems he had prepared; so he
decided to give them one last challenge:
Print the number of integers having N digits where the digits form a non decreasing sequence.
Input Specification
Input will start with T <= 100 number of test cases. Each test case consists of a single line having
integer N where 1 <= N <= 100000.
Output Specification
For each test case print on a separate line the number of valid sequences modulo 1000000007.
Sample Input
3
2
3
4
Sample Output
55
220
715
这题是想要暴力的弟弟们妹妹们,放弃治疗吧,看到没?输出都对10亿取模了,好吧,不啰嗦了,这个小题的搞法呢是一位一位去考虑,当然就是传说中的“打表”了,你想啊,题目要求的是非递减,所以我只要从少一位的里面所有数考虑,比如12,我要加一位(只说加最前面,其实一样的),要满足条件就只能是112和012了,快要搞不清了,直接上代码再喷口水吧
#include <iostream>
#define mod 1000000007
using namespace std;
int main (void)
{
int t,n,i,j,k,l,xx[10]={1,1,1,1,1,1,1,1,1,1},d[100001]={0,10}; //xx里面是最高位数字能有的数字数量,d就是要打的表
for(i=2;i<100001;i++)
{
for(j=9;j>=0;j--) //从大的向小的找,像我要加一位,当前最高位数字是9,那么我可以加9、8、7、6、5、4、3、2、1、0
for(k=j-1;k>=0;k--) //当然本身xx[j]就是保存了数据的,所以直接从j-1开始加
xx[j]=(xx[j]+xx[k])%mod; //要取模
for(j=0;j<10;j++) //把当前位数的结果装进表中
d[i]=(d[i]+xx[j])%mod;
}
cin>>t;
while(t--&&cin>>n)
{
cout<<d[n]<<endl;
}
return 0;
}
一两句话说不清楚,那就举例子好一点
最高位数字 0 1 2 3 4 5 6 7 8 9
1位: 1 1 1 1 1 1 1 1 1 1 //因为一位数的时候满足条件的只有0,1,2,3,4,5,6,7,8,9,每个数字在最高位只有一次
2位: 1 2 3 4 5 6 7 8 9 10 //两位数我0开头的就是00,1开头的是10,11,2开头是20,21,22.....这下有头绪了没?--!2位的时候我只要看1位的时候最高位数字的个数,然后哪些是可以加上去的我就加上去,怎么样?是不是蛮哈皮的搞法?亲~~
HUNNU--湖师大--11409--Skill的更多相关文章
- hunnu 11313 无重复元素序列的最长公共子序列转化成最长递增子序列 求法及证明
题目:http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11313 湖师大的比赛,见我的另一篇水题题解,这里要说的 ...
- python瓦登尔湖词频统计
#瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as tex ...
- 华为云FusionInsight湖仓一体解决方案的前世今生
摘要:华为云发布新一代智能数据湖华为云FusionInsight时再次提到了湖仓一体理念,那我们就来看看湖仓一体的来世今生. 伴随5G.大数据.AI.IoT的飞速发展,数据呈现大规模.多样性的极速增长 ...
- 【转】What is an SDET? Part 2 – Skill Matrix of SDET
What is an SDET? Part 2 ---- Skill Matrix of SDET (Instead of naming it as part 2 of What is an SDET ...
- 为川师大女生支招 15年如何还200W
就在昨儿一条新闻火遍全网,川师大21岁女生樊师贝发帖称,希望有人借她200万,为父母在城里买房15年还清,至于利息“可以用后半生来陪伴你”.她说,六旬父亲要负担家用,哥哥啃老,而她目前一分钱都还没挣到 ...
- hihoCoder 1425 : What a Beautiful Lake(美丽滴湖)
hihoCoder #1425 : What a Beautiful Lake(美丽滴湖) 时间限制:1000ms 单点时限:1000ms 内存限制:256MB Description - 题目描述 ...
- 一塔湖图(codevs 1024)
题目描述 Description 小松所在的PK大学校园又称作燕园,是一个十分美丽的校园.有博雅塔,未名湖,亚洲最大的高校图书馆,人称“一塔湖图”.但是由于燕园的历史比较悠久,所以很多的老房子都要不断 ...
- Skill
Skill Yasser is an Egyptian coach; he will be organizing a training camp in Jordan. At the end of ca ...
- 湖大 11404 manacher
链接 http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11404&courseid=0 求 最长回文 ...
- hunnu Sum of f(x)
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11546&courseid=0 Sum of f(x) ...
随机推荐
- C语言-06数据类型-05 总结
一.基本数据类型1.int1> long int.long:8个字节 %ld2> short int.short:2个字节 %d %i3> unsigned int.unsigned ...
- Makefile的简单例子
1.生成test可执行文件,源文件有prog.c prog.h cord.h test:prog.o code.o gcc -o test prog.o code.o prog.o:prog.c pr ...
- IE8,IE9,IE10绿色版,以及ColorPix
对于开发者而言IETest是一坨屎. 但是我们终于迎来的蛋糕和火腿,今天无意间发现了竟然有绿色版的浏览器版本,IE9,IE10已经下到本地,IE8网传是有的,但是没有找到合适的版本.但是足够了,本机使 ...
- Struts2技术内幕-----第七章
1)基于人机交互的请求--响应模式主要由哪三大要素构成? ①沟通协议-----人和机器都能够明白的数据通信格式 ②请求内容-----人通过某种机制向机器发起的数据请求 ③响应内 ...
- [HDOJ - 5208] Where is Bob 【DFS+按位贪心】
题目链接:HDOJ - 5208 题目分析 使用按位贪心的思想,即从高位向低位枚举,尽量使这一位的答案为 1 . 我们使用 DFS ,每次就是对于 [l1, r1] [l2, r2] x 进行处理 ...
- 对话机器学习大神Yoshua Bengio(下)
对话机器学习大神Yoshua Bengio(下) Yoshua Bengio教授(个人主页)是机器学习大神之一,尤其是在深度学习这个领域.他连同Geoff Hinton老先生以及 Yann LeCun ...
- ireport常见问题
$V{PAGE_NUMBER} 表示当前是第几页 ,在text field 的 选项evaluation time选report是共几页,now表是当前页.页码可在ireport里直接设置. &quo ...
- 【POJ1275】Cashier Employment
题目: Description A supermarket in Tehran is open 24 hours a day every day and needs a number of cashi ...
- linux下mysql的安装
一.下载 http://dev.mysql.com/downloads/mysql/ 选择对应的版本,这里选择“Linux-Generic” 以64位系统为例,这里需要下载如下两个文件: MySQL- ...
- 14.6.3.5 Configuring InnoDB Buffer Pool Flushing
14.6.3.5 Configuring InnoDB Buffer Pool Flushing InnoDB 执行某些任务在后台, 包括脏叶的刷新(那些已经发生改变的pages 但是没有写入到数据文 ...