E. Okabe and El Psy Kongroo     Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as all points…
E. Okabe and El Psy Kongroo   Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as all points (…
E. Okabe and El Psy Kongroo time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to k…
题目链接:http://codeforces.com/contest/821/problem/E 题意:我们现在位于(0,0)处,目标是走到(K,0)处.每一次我们都可以从(x,y)走到(x+1,y-1)或者(x+1,y)或者(x+1,y+1)三个位子之一. 现在一共有N段线段,每条线段都是平行于X轴的.我们如果此时x是在这段线段之内的话,我们此时走到的点(x,y)需要满足0<=y<=Ci. 现在保证一段线段的终点,一定是下一段线段的起点.问我们从起点走到终点的行走方案数. 题解:简单的dp+…
题意: 有b个blocks,每个blocks都有n个相同的0~9的数字,如果从第一个block选1,从第二个block选2,那么就构成12,问对于给定的n,b有多少种构成方案使最后模x的余数为k. 分析: dp+矩阵快速幂. 假如现在的数是m,模x余数是n,那么再从下一个block中选一个数a,a模x余数为b,那么新的数的余数就为(m∗10+a)%x,也就是(n∗10+b)%x,所以实际上我们只需要直接对余数进行操作.容易得到状态转移方程,其中dp[i][j]表示从第i个block中选择一个数后…
题意:我们现在位于(0,0)处,目标是走到(K,0)处.每一次我们都可以从(x,y)走到(x+1,y-1)或者(x+1,y)或者(x+1,y+1)三个位子之一.现在一共有N段线段,每条线段都是平行于X轴的.我们如果此时x是在这段线段之内的话,我们此时走到的点(x,y)需要满足0<=y<=Ci.现在保证一段线段的终点,一定是下一段线段的起点.问我们从起点走到终点的行走方案数. dp方程比较显然:dp[i][j]+=dp[i-1][j]+dp[-1][j-1]+dp[i-1][j+1] 之后构造一…
E. Okabe and El Psy Kongroo time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to k…
题意:(0,0)走到(k,0),每一部分有一条线段作为上界,求方案数. 解题关键:dp+矩阵快速幂,盗个图,注意ll 关于那条语句为什么不加也可以,因为我的矩阵C,就是因为多传了了len的原因,其他位置都是0,所以不需要加 #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<iostream>…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985 We define a kind of strings as elegant string: among all the substrings of an elegant string, none of them is a permutation of "0, 1,…, k". Let function(n, k) be the number of elegant s…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5434 Peace small elephant  Accepts: 38  Submissions: 108  Time Limit: 10000/5000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 小明很喜欢国际象棋,尤其喜欢国际象棋里面的大象(只要无阻挡能够斜着走任意格),但是他觉得国际象棋里的大象太凶残了…