ural 1009. K-based Numbers(简单dp)】的更多相关文章

http://acm.timus.ru/problem.aspx?space=1&num=1009 题意:将一个n位数转化为合法的K进制数,有多少种情况.合法的K进制数即不含前导0,且任意两个0都不相邻. 思路:每一位的情况都分为:小于K且不等于0的情况或等于0的情况,每一位的选择都有前一位决定.dp[i][0]表示第i位为0的情况,dp[i][1]表示第i位不为0的情况,则 dp[i][0] = dp[i-1][1],dp[i][1] = (dp[i-1][1]+dp[i-1][0])*(k-…
题目传送门 题意:n位数,k进制,求个数分析:dp[i][j] 表示i位数,当前数字为j的个数:若j==0,不加dp[i-1][0]; 代码1: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int MAXN = 22; const int INF = 0x3f3f3f3f; long long…
题目:Click here #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; ; int n, k; ][][]; // dp[i][j][k]表示i进制下j位数以k结尾的个数(k=0表示以0结尾:k=1表示不以0结尾) int main() { ; i<=; i++ ) { dp[i][][] = ; dp[i][][] = i-; ; j<…
http://acm.timus.ru/problem.aspx?space=1&num=1203 按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理,从这个时间开始的任务都正要被处理, 因为t<=3e5,可以用简单dp解决 #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e5+5; int n; typedef pair&l…
题目地址:space=1&num=1635">Ural 1635 又是输出路径的DP...连着做了好多个了. . 状态转移还是挺简单的.要先预处理出来全部的回文串,tag[i][j]为1表示字符串i--j是一个回文串.否则不是回文串.预处理时要用n^2的方法.即枚举回文串中间.能够分奇数和偶数两种分别求一次. 然后dp转移方程为,若tag[j][i]==1,dp[i]=min(dp[i],dp[j-1]+1); 对于最令人讨厌的路径输出.能够用pre来记录回文串前驱分裂点,然后依据…
免费馅饼 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 102   Accepted Submission(s) : 35 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 711    Accepted Submission(s): 354 Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However,…
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Noura Boubou is a Syrian volunteer at ACM ACPC (Arab Collegiate Programming Contest) since 2011. She graduated from Tishreen Un…
dp[i][j]代表以s[i][j]字符为右上角的最大对称方阵的尺寸 最左边那一列都为1,然后按列更新,代码实现比较简单,感觉有点卡时间,如果对称度很好,时间应该比较高,我只会这种了 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<cstring> #include<cstring…