hdu_5676_ztr loves lucky numbers
题目连接: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>
#include<queue>
#include<algorithm>
#include<functional>
#define cl(a,b) memset(a,b,sizeof(a));
#define FFC(i,a,b) for(int i=a;i<=b;i++)
#define FFI(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define LL long long
using namespace std;
void fre(){freopen("c:\\acm\\input.txt","r",stdin);}
using namespace std;
int k[];
LL f[];
int e[];
int main(){
int cnt=;
for(int i=;i<=;i+=){
for(int j=;j<i/;j++)e[j]=;
for(int j=i/;j<i;j++)e[j]=;
do{
for(int j=;j<i;j++)f[cnt]=f[cnt]*+e[j];
cnt++;
}while(next_permutation(e,e+i));
}//运用排列组合,将所有数算出来并保存
int t;
scanf("%d",&t);
while(t--){
LL n;
scanf("%I64d",&n);
if(n>777777777444444444LL){
printf("44444444447777777777\n");
continue;
}
int pos=lower_bound(f,f+cnt,n)-f;
printf("%I64d\n",f[pos]);
}
return ;
}
hdu_5676_ztr loves lucky numbers的更多相关文章
- HDU 5676 ztr loves lucky numbers (模拟)
ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...
- hdu 5676 ztr loves lucky numbers(dfs+离线)
Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...
- hdu 5676 ztr loves lucky numbers 打表+二分
ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- hdu-5676 ztr loves lucky numbers(乱搞题)
题目链接: ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- hdu 5676 ztr loves lucky numbers
题目链接:hdu 5676 一开始看题还以为和数位dp相关的,后来才发现是搜索题,我手算了下,所有的super lucky number(也就是只含数字4, 7且4, 7的数量相等的数)加起来也不过几 ...
- hdu5676 ztr loves lucky numbers(dfs)
链接 ztrloveslucky numbers 题意 定义幸运数为:只存在4和7且4和7数量相等的数,给出n,求比>=n的最小幸运数 做法 暴力搜出所有长度从2-18的幸运数,因为最多9个4, ...
- ztr loves lucky numbers 傻逼的我来了个大模拟
http://acm.hdu.edu.cn/showproblem.php?pid=5676 这题的正解因该是dfs的,但是有18个位,然后我一算,全排列的话,有18!个啊,那不是很大?但是有很多是相 ...
- HDU 5676 ztr loves lucky numbers【DFS】
题目链接; http://acm.hdu.edu.cn/showproblem.php?pid=5676 题意: 由4和7组成的且4和7出现次数相同的数称为幸运数字,给定n,求不大于n的最大幸运数字. ...
- ZCMU 2177 Lucky Numbers (easy)
传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec ...
随机推荐
- springMVC servlet 静态资源加载
问题描述 新手使用SpringMVC时市场会遇到静态资源无法加载在问题,如下图所示 问题原因 出现这种问题一般是在web.xml中的对spring的DispatcherServlet采用了如下配置,即 ...
- Docker 安装及问题处理
1 确定Linux版本 uname -r 2 升级系统(添加 APT 镜像源,添加使用 HTTPS 传输的软件包以及 CA 证书.) sudo apt-get update sudo apt-get ...
- Convert a byte[] array to readable string format. This makes the "hex" readable!
/* * Java Bittorrent API as its name indicates is a JAVA API that implements the Bittorrent Protocol ...
- sql 关于dblink和多条update、insert事务回滚写法
在存储过程的编写中难免会遇到调用同库他人的proc和跨库调用proc,还有一个proc中有多条对多表进行写入和修改的语句.那么就会用到tran. 如果我们在不写try的情况下就要对每个insert,u ...
- Linux用户相关的操作命令
1.建用户: adduser phpq //新建phpq用户 passwd phpq //给phpq用户设置密码 2.建工作组 groupadd test //新建 ...
- 老司机的奇怪noip模拟T1-guanyu
1. 关羽(guanyu.cpp/c/pas )[问题描述]xpp 每天研究天文学研究哲学,对于人生又有一些我们完全无法理解的思考.在某天无聊学术之后, xpp 打开了 http://web.sang ...
- PostgreSQL ----- No relations found.
本篇文章可能有错,尚未细细研究 运行\d出错: No relations found. \d只显示可见的表,也就是该数据库的schema在search_path中. SHOW search_path; ...
- JavaScript的正则表达式
1.文本框只能输入数字(不包括小数点) <input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpas ...
- SBT详解
文章转载自http://beike.iteye.com/blog/1575296 SBT = (not so) Simple Build Tool,是scala的构建工具,与java的maven地位相 ...
- Gentoo网络配置
网卡识别配置 要开始配置你的网卡,你首先需要告诉Gentoo RC系统你的网卡. 可以用ifconfig命令查看自己网卡名字: ifconfig -a 网卡名字(如eth0)的识别是通过在/etc/i ...