hdu-5676 ztr loves lucky numbers(乱搞题)】的更多相关文章

题目链接: 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​​)组数…
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…
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…
题意:要把一块n*m*k的巧克力分成1*1*1的单元,有两种操作方式:1,用手掰(假设力量无穷大),每次拿起一块,掰成两块小的:2,用刀切(假设刀无限长),可以把多块摆在一起,同时切开.问两种方式各需多少次操作才能完成任务. 分析:用手掰很明显是(n*m*k-1)次操作.用刀切注意不是((n-1)+(m-1)+(k-1))次操作,这只是不动原巧克力的操作数.举个例子:1*1*4的巧克力,用刀切,按上面说的要3次操作,实际上只需2次.所以不管是长宽高,都只需要[log2n](或m,k)次操作. 注…
题目链接: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<…
题目链接:http://codeforces.com/problemset/problem/402/C /**算法分析: 乱搞题,不明白题目想考什么 */ #include<bits/stdc++.h> #define MAXN 1050 #define PI acos(-1.0) #define REP(i,n) for(int i=0; i<n; i++) #define FOR(i,s,t) for(int i=s; i<=t; i++) #define mem(a,b) m…
题目链接 Description Final Pan likes prime numbers very much. One day, he want to find the super prime numbers.A prime numbers $n$($n$>4) is a super prime number only if $n$-4 and $n$+4 are both prime numbers,too. Your task is really easy:Give $N$,find t…
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.…
//真tm是乱搞 但是(乱搞的)思想很重要 解:大概就是记忆化搜索,但是原数据范围太大,不可能记下所有的情况的答案,于是我们就在记下小范围内的答案,当dfs落入这个记忆范围后,就不进一步搜索,直接返回记下来的答案,这样就起到了优化的效果,但是并不知道这种复杂度是怎么算的.然而我们由大到小排序,使得状态总可以很快地落入记忆化的范围. dfs(n,now)代表[1..n]内不会被a[now]...a[k-1]整除的数有多少,那么答案就是dfs(n,0). 转移关系如下:dfs(n,now)=dfs(…
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…
题目链接: C. Bear and Up-Down time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The life goes up and down, just like nice sequences. Sequence t1, t2, ..., tn is called nice if the following two…
题目链接: B. Rebus time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' an…
MG loves apple  Accepts: 20  Submissions: 693  Time Limit: 3000/1500 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 MGMG是一个财富爆表的男孩子.他拥有N(1<=N<=100000)N(1<=N<=100000)个苹果,每个苹果上标有一个数字00~99,代表它的价值. 一个合法的数字是不含有前导零的,这nn个苹果恰好排成了一个…
题目连接: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…
Hanoi Tower Troubles Again! Problem Description People stopped moving discs from peg to peg after they know the number of steps needed to complete the entire task. But on the other hand, they didn't not stopped thinking about similar puzzles with the…
这题也是一眼标算..... 先搞一次dfs,把树转换成序列,对每个节点看子树的中位数,也就是看某段区间的中位数,这样就可以主席树求区间第k大值解决. 注意:询问的次数有1000000次,每次去询问会TLE的.注意到询问的种类只有100000种,所以之前询问过的可以0(1)得到,或者直接处理出每一种询问的答案. 还有一个问题:小数取模...用fmod函数. #include<cstdio> #include<cstring> #include<cmath> #includ…
B. DZY Loves FFT 题目连接: http://codeforces.com/contest/444/problem/B Description DZY loves Fast Fourier Transformation, and he enjoys using it. Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are s…
Manacher+二维费用多重背包 二进制优化 这题是一眼标算....先计算出每个长度的回文串有几种,然后用二维费用的多重背包判断是否有解. 多重背包做的时候需要二进制优化. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; int N, p[maxn]; char str[maxn], b[maxn]; int cnt[…
题目链接: D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs…
MG loves string    Accepts: 30    Submissions: 67  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) 问题描述 MGMG是一个很忙碌的男孩子.今天他沉迷于这样一个问题: 对于一个长度为NN的由小写英文字母构成的随机字符串,当它进行一次变换,所有字符ii都会变成a[i]a[i]. MGMG规定所有a[i]a[i]构成了2626个…
题目大意: 每个人有五门课成绩,初始给定一部分学生的成绩,然后每次询问给出一个学生的成绩,希望知道在给定的一堆学生的成绩比这个学生每门都低或者相等的人数 因为强行要求在线查询,所以题目要求,每次当前给定的学生成绩都异或上一次的答案 先将学生按每一门成绩都排一次序 这里将学生分块成sqrt(n)的块数,然后在当前块中用bitset容器来记录含有学生的状态 这里可以记录状态的前缀和,因为比后面成绩好的,必然比前面的学生的成绩也好 查询的时候只要查到正好比他高的学生属于哪一块,这样只要访问sqrt(n…