ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For…
Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Lucky number is…
ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1834    Accepted Submission(s): 707 Problem Description ztr loves lucky numbers. Everybody knows that positive integers ar…
题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几万个,可以采用打表的方法来把所有的super lucky number存储起来.因为4,7数量须相等,所以可以用一个二进制数的0,1来代替,先限定4,7数量分别为 i,之后就是求出包含 i 个0和 i 个1的 2*i 位所有这样的二进制数,然后简单转换一下(1->7, 0->4,这样子能从小到大…
题目链接; http://acm.hdu.edu.cn/showproblem.php?pid=5676 题意: 由4和7组成的且4和7出现次数相同的数称为幸运数字,给定n,求不大于n的最大幸运数字. 分析: 可以对于每个数都按位dfs找一发.一旦发现当前位无法满足就回溯,直到找到满足条件的最小的. 也可以先按位dfs把所有结果都找出来存起来,然后对于每个询问直接二分即可.注意边界时会爆long long,注意处理. 代码: #include<cstdio> #include<cstri…
题目链接: ztr loves lucky numbers  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) 问题描述 ztr喜欢幸运数字,他对于幸运数字有两个要求 1:十进制表示法下只包含4.7 2:十进制表示法下4和7的数量相等 比如47,474477就是 而4,744,467则不是 现在ztr想知道最小的但不小于n的幸运数字是多少 输入描述 有TT(1≤T≤10​5​​)组数…
http://acm.hdu.edu.cn/showproblem.php?pid=5676 这题的正解因该是dfs的,但是有18个位,然后我一算,全排列的话,有18!个啊,那不是很大?但是有很多是相同的,因为4477和第一个和第二个数字调转的结果是一样的. 先说说我模拟的方法. 真的很麻烦,不想看的,给几组数据就跑 70845004755444477787847777445 我是贪心模拟前n位,模拟的时候,如果这一位是3,如果我还有4,那么证明比后面的大了,然后后面的直接按4优先输出即可. 还…
链接 ztrloveslucky numbers 题意 定义幸运数为:只存在4和7且4和7数量相等的数,给出n,求比>=n的最小幸运数 做法 暴力搜出所有长度从2-18的幸运数,因为最多9个4,9个7,再大的话好像数组存不下只能特判了,然后二分找出比这个数大的那个数就行了 代码 #include<bits/stdc++.h> using namespace std; #define LL long long LL n[1100000]; int s4, s7, len, t; void…
题目链接:HDU 5677 ztr loves substring 题意:有n个字符串,任选k个回文子串,问其长度之和能否等于L. 题解:用manacher算法求出所有回文子串的长度,并记录各长度回文子串的个数,再用背包思想判断是否有解. dp[i][j]:选取i个回文子串,长度之和是否为j 其中用到二进制分解思想,将回文串长为i的数量cnt[i]拆成1+2+4+8+…形式,进行优化. #include<cstdio> #include<algorithm> #include<…
ztr loves math 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/A Description ztr loves research Math.One day,He thought about the "Lower Edition" of triangle equation set.Such as n = x^2 - y^2. He wanted to know that ,for a given numb…
ztr loves math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 896    Accepted Submission(s): 347 Problem Description ztr loves research Math.One day,He thought about the "Lower Edition" of…
Problem Description ztr loves research Math.One day,He thought about the "Lower Edition" of triangle equation set.Such as n=x2−y2. He wanted to know that ,for a given number n,is there a positive integer solutions? Input There are T test cases.…
ztr loves substring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 219    Accepted Submission(s): 119 Problem Description ztr love reserach substring.Today ,he has n string.Now ztr want to kon…
NanoApe Loves Sequence 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5805 Description NanoApe, the Retired Dog, has returned back to prepare for the National Higher Education Entrance Examination! In math class, NanoApe picked up sequences once aga…
NanoApe Loves Sequence Ⅱ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5806 Description NanoApe, the Retired Dog, has returned back to prepare for for the National Higher Education Entrance Examination! In math class, NanoApe picked up sequences on…
题目链接: http://poj.org/problem?id=3899 题目意思: 求给定区间内,只含4.7的数的个数以及通过反转后在该区间内的个数和. 解题思路: 模拟+数学. 代码解释的很详细,请看代码. #include<iostream> #include<cmath> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5676 在这%一下安神,用了我没见过的黑科技next_permutation,至少我是今天才知道的 #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<set> #include<map> #include<vector> #i…
http://acm.hdu.edu.cn/showproblem.php?pid=5676 题目大意: 给你一个数  让你找比这数大并且只含4和7  并且4和7的个数一样 枚举从0到10的18次方之间的所有的可能的数  在用二分搜索 因为20位超过longlong   所以特判一下 #include<stdio.h> #include<math.h> #include<algorithm> #include<iostream> #include<st…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 178    Accepted Submission(s): 93 Problem Description ztr love reserach substring.Today ,he has n string.Now ztr want to konw,can he take out exac…
题意:计算Bestcoder四题的得分. 思路:直接模拟,4项分数直接计算后输出.注意不要低于百分之40的分. //#include <bits/stdc++.h> #include <iostream> #include <cstdio> #define LL long long using namespace std; ; int a[N]; int b[N]; int cal() { ; ans=(/*(-a[])-b[]* >*/*(-a[])-b[]*:…
题目链接:点击传送 MG loves apple Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description MG is a rich boy. He has n apples, each has a value of V(0<=V<=9). A valid number does not contain a leading zero, and…
题目链接 Problem Description Kblack loves flags, so he has infinite flags in his pocket. One day, Kblack is given an chessboard and he decides to plant flags on the chessboard where the position of each flag is described as a coordinate , which means tha…
这题也是一眼标算..... 先搞一次dfs,把树转换成序列,对每个节点看子树的中位数,也就是看某段区间的中位数,这样就可以主席树求区间第k大值解决. 注意:询问的次数有1000000次,每次去询问会TLE的.注意到询问的种类只有100000种,所以之前询问过的可以0(1)得到,或者直接处理出每一种询问的答案. 还有一个问题:小数取模...用fmod函数. #include<cstdio> #include<cstring> #include<cmath> #includ…
Manacher+二维费用多重背包 二进制优化 这题是一眼标算....先计算出每个长度的回文串有几种,然后用二维费用的多重背包判断是否有解. 多重背包做的时候需要二进制优化. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; int N, p[maxn]; char str[maxn], b[maxn]; int cnt[…
传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec  内存限制: 256 MB提交: 42  解决: 21[提交][状态][讨论版] 题目描述 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard ou…
Problem description Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Lucky number…
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个L,问能组成[L,R]全部数字的情况下,R的最大值是多少 思路:暴力C(20, 6),然后对于每一个序列去全排后模拟计算值, 只是之前要有个剪枝.全排前.先把k个数随机取数(即不用连续),然后假设这样还满足不了,那么连续的情况肯定也满足不了.直接结束.不进入全排.这样一来因为满足不了的情况实际上是占…
Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1444    Accepted Submission(s): 329 Problem Description Dylans is given a tree with N nodes. All nodes have a value A[i].Nodes…
I - pog loves szh III Time Limit:6000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5266 Description Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of the t…
DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves partitioning numbers. He wants to know whether it is possible to partition n into the sum of exactly k distinct positive integers. After some thinking he f…