05 2013 档案
摘要:每个格子有3种状态,放置这1*2的长方体的3中方法,然后广搜就OK了,因为每移动一格都是一步,所以广搜就是最短路了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<cmath> 6 #include<algorithm> 7 #include<queue> 8 using std::queue; 9 struct node 10 { 11 int x1,x2,y1,y2,s;
阅读全文
摘要:7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要求Ri > Ri+1且Hi > Hi+1。由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积Q最小。令Q = Sπ请编程对给出的N和M,找出蛋糕的制作方案(适当的Ri和Hi的值),使S最小。 (除Q外,以上所有数据皆为正整数)有两行,第一行为N(N <= 10000),表示待制作的蛋糕的体积为Nπ;第二行为M(M <
阅读全文
摘要:101为镜子数,100不是,并且121也不是,因为2反过来会变成s形,所以这题的思路只用考虑0,1,8也就是一个三进制的数就可以了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<cstdlib> 6 #include<algorithm> 7 using std::cout; 8 using std::endl; 9 using std::cin;10 typedef long long L
阅读全文
摘要:题目意思:要求数字偶数数位出现基数次,基数数位出现偶数次,不出现,不违反规则。状态压缩:3进制数 0表示未出现过 1表示出现基数次 2表示出现偶数次 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 #include<algorithm> 6 #include<cmath> 7 using std::cin; 8 using std::endl; 9 using std::cout;10 typedef lon
阅读全文
摘要:101010属于周期循环的二进制,循环次数为3现在给你十进制的区间,求出有周期循环的数的个数思路: 枚举循环的周期的长度,但注意周期长度所包含的因子长度不能重复计算。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 typedef long long LL; 6 int const N = 70; 7 LL dp[N],p2[N]; 8 int bit[N],ln; 9 void pre()10 {11 p2[0]=1;12 for
阅读全文
摘要:题意:1245 这个数属于上升长度为4的数字,1213这个数字属于上升长度为3的数字。统计区间[l,r]中上升长度为k的数字个数。State 状态压缩,表示最长上升的序列用到的数字有哪些 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 typedef long long LL; 6 int const N = 22; 7 int const M = 1030; 8 int bit[N],ln,pow2[11],k; 9 LL dp[
阅读全文
摘要:主要是记录一个flag,表示现在距离幸运位的位置有多远,然后做一下记忆化的搜索就OK了。。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 #include<cmath> 6 #define MOD 1000000007 7 using namespace std; 8 typedef long long LL; 9 int const N = 2010;10 int ln,k;11 char bitl
阅读全文
摘要:统计n以下所有有x次4和y次7的数的个数,然后二分。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 typedef long long LL; 7 int const N = 22; 8 int const M = 22; 9 LL dp[N][N][N];10 int bit[N],ln;11 int x,y;12 LL getsum1(int t,int limi
阅读全文
摘要:其实我不知道要说什么,因为这道题的解法也是从别人那里看的,不想盗版,看看这位神牛的吧,讲得挺不错,就是要好生理解一下。http://blog.csdn.net/xymscau/article/details/6688671View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 typedef long long LL; 6 int const N = 33; 7 LL dp[N],pow2[N]; 8 void pre(
阅读全文
摘要:Start with an integer,N0, which is greater than 0. LetN1be the number of ones in the binary representation ofN0. So, ifN0= 27,N1= 4. For alli> 0, letNibe the number of ones in the binary representation ofNi-1. This sequence will always converge to one. For any starting number,N0, letKbe the minim
阅读全文
摘要:说白了,只要求出1-x中出现666子串的数字,然后二分枚举答案。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 typedef long long LL; 6 int const N = 20; 7 LL dp1[N][N][N],dp2[N][N][N]; 8 int bit[N],ln; 9 LL getsum1(int t,int pre,int last,int flag,int limit)10 {11
阅读全文
摘要:枚举数位之和,然后取磨直到最后,记忆化减少时间复杂度。View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 typedef long long LL; 6 int const N = 11; 7 int const M = 82; 8 int dp[N][M][M][M]; 9 int bit[N],l,uup;10 int getsum1(int t,int pre,int sum,int limit,int res
阅读全文
摘要:统计数字当中出现13的子串,并且能被13整除的数字。逐位确定一下就Ok了,然后加好其他限定条件,减少时间复杂度用记忆化。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 typedef long long LL; 6 int const N = 20; 7 int const M = 15; 8 int bit[N],l; 9 LL dp1[N][M][M],dp2[N][M][M];10 LL getsum1(i
阅读全文
摘要:For example, 4139 is a balanced number with pivot fixed at 3. The torqueses are 4*2 + 1*1 = 9 and 9*1 = 9, for left part and right part, respectively. It's your job to calculate the number of balanced numbers in a given range [x, y].思路:枚举中心轴的位置,然后针对这个位置,算出结果,结果记得去掉全0的情况。View Code 1 #include<i
阅读全文
摘要:如果这个数要被自己的每个数位上的数整除,那么这个数一定能被每个数位上的最小公倍数整除。那么剩下的就是用记忆话搜索和枚举来解题了。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cmath> 6 typedef long long LL; 7 int const M = 55; 8 int const N = 20; 9 int const MOD= 2520;10 LL l,r;11
阅读全文
摘要:windy定义了一种windy数。不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。windy想知道,在A和B之间,包括A和B,总共有多少个windy数? 解题思路:简单枚举+记忆化搜索View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cmath> 6 using std::cout; 7 using std::endl; 8 typedef long long LL;
阅读全文
摘要:dp[i][3],其中i表示位数,后面的3表示有三种数 0:首位不带9的合法数 1:首位带9的合法数 2:不合法数View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 typedef long long LL; 6 int const N = 20; 7 LL dp[N][3],n,pow10[20];//0合法的数字个数 1以9开头的合法数字 2不合法的数字 8 int bit[N],t; 9 void pre()1
阅读全文
摘要:吉哥他生平最恨情人节,不管是214还是77,他都讨厌! 吉哥观察了214和77这两个数,发现: 2+1+4=7 7+7=7*2 77=7*11 最终,他发现原来这一切归根到底都是因为和7有关!所以,他现在甚至讨厌一切和7有关的数! 什么样的数和7有关呢? 如果一个整数符合下面3个条件之一,那么我们就说这个整数和7有关—— 1、整数中某一位是7; 2、整数的每一位加起来的和是7的整数倍; 3、这个整数是7的整数倍; 现在问题来了:吉哥想知道在一定区间内和7无关的数字的平方和。解题思路:如果确定了一个数字x,然后确定要在最高位添加一个i的数字,那么此时该数字等于(10^X的位...
阅读全文
摘要:说实在的,有点惭愧,这题,本来想用更好的办法,但是时间复杂度更高了。朴素的办法就是打表,从1-1000000打一个统计1-n中的合格数的表。递归枚举其中的数字:View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 int const N = 20; 7 int l,r,n,m,num,sl[N],sr[N]; 8 int pow10[8],sl2[N],sr2[N]; 9
阅读全文
摘要:题意:有一位售票员现在要将手中的一系列连续的票卖给客人,而且是卖出连续的票给客人,而现在卖出的票的编号的数位之和不能小于k这个正整数,求按照这样的规则我能售票给多少位乘客。算法合集之《浅谈数位类统计问题》当中就讲到过,要我们以进制叉树的形式来具象化所有的数的情况。我们就是要找出l到r中的连续数超过k的组数,尽可能的多。但是现在关于合并子树的问题就是,其中有一部分客人手机的票超过了k,并找有一部分超过k的部分,那么这就使得我们再累加子树的时候添加了困难的地方。现在引入一个dp的思想,说实话此类的问题这样的思想还是比较先进的,就是难得想到。Dp[i][j][m]其中有co,rest两个值,其中表示
阅读全文

浙公网安备 33010602011771号