Mirror Number SPOJ - MYQ10】的更多相关文章

Mirror Number SPOJ - MYQ10 题意:http://blog.csdn.net/hcbbt/article/details/38349367 稍微改一下http://www.cnblogs.com/hehe54321/p/loj-1205.html就行 #include<cstdio> #include<cstring> typedef long long LL; LL ans[][][]; LL w[]; LL T; ],r[]; LL temp[]; LL…
题意 询问区间[a,b]中的Mirror Number的个数,其中Mirror Number是指把它横着翻转后还能表示同样的数字. 思路 注意这个可不是回文数..除了0,1,8,别的数字翻转过后就不是数字了.所以策略就是记忆化按位搜索,每位只搜0,1,8,最后再判断是否回文,统计即可.这个判断回文是个小麻烦,因为它需要和前面的位相比较,所以用一个全局数组tmp[]表示枚举的每位的数字. 回过头来我觉得设置全局变量似乎不是一个好方法--它应该会破坏DP数组的区间唯一性-- 代码 [cpp] #in…
这周开始刷数位DP,在网上找到一份神级数位DP模板,做起题目来爽歪歪. http://www.cnblogs.com/jffifa/archive/2012/08/17/2644847.html int dfs(int i, int s, bool e) { ) return s==target_s; if (!e && ~f[i][s]) return f[i][s]; ; ; :; d <= u; ++d) res += dfs(i-, new_s(s, d), e&&a…
[SPOJ]NUMOFPAL - Number of Palindromes(Manacher,回文树) 题面 洛谷 求一个串中包含几个回文串 题解 Manacher傻逼题 只是用回文树写写而已.. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<…
题目链接:http://poj.org/problem?id=2104 Description You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickl…
Number of Palindromes Time Limit: 100MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Submit Status Description Each palindrome can be always created from the other palindromes, if a single character is also a palindrome. For example, the…
题目描述 English Vietnamese You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickly k-th order statistics…
Shadowman loves to collect box but his roommates woogieman and itman don't like box and so shadowman wants to hide boxes as many as possible. A box can be kept hidden inside of another box if and only if the box in which it will be held is empty and…
传送门 题意: 给出了三个新定义: E-prime : ∀ num ∈ E,不存在两个偶数a,b,使得 num=a*b;(简言之,num的一对因子不能全为偶数) E-prime factorization : 定义集合P由 E-prime 元素组成,定义 e = p1*p2*.....*pn:(p1,p2,....,pn ∈ P , |P| = n) E-factorial : 定义 e!! = 2*4*6*8*.........*e:(简言之,偶数e及其之前的偶数连乘积) 输出一个数 e ,求…
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elem…