hdu_5676_ztr loves lucky numbers
2016-04-30 23:25
330 查看
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5676
在这%一下安神,用了我没见过的黑科技next_permutation,至少我是今天才知道的
在这%一下安神,用了我没见过的黑科技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[20]; LL f[100001]; int e[50]; int main(){ int cnt=0; for(int i=2;i<=18;i+=2){ for(int j=0;j<i/2;j++)e[j]=4; for(int j=i/2;j<i;j++)e[j]=7; do{ for(int j=0;j<i;j++)f[cnt]=f[cnt]*10+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 0; }
相关文章推荐
- Android中如何自己创造一个Cursor及MatrixCursor源码分析
- C++模板
- Python学习笔记15
- 2016_04_30_第一次为校赛命题
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- 设计新的Android HTTP请求封装类
- SaaS多租户数据隔离的三种方案
- 第9周学习进度
- win8及以上2012 R2,virtualbox 5.0.20安装centOS6以上各种注意事项
- 为何bash中一条命令的输出保存到变量之后换行符变成了空格
- Spring事务——Spring 2.X的事务配置策略
- js中的call和apply方法的区别
- Spring事务——使用TransactionProxyFactoryBean创建事务代理
- 我的第一篇博客
- 使用JRegex抽取网页信息
- day55-hive实战:
- LA 3266 Tian Ji -- The Horse Racing (贪心 || DP)
- 明天(2016/5/1)晚上8:00-9:00在"webrtc源码分析群"qq群,开讲webrtc源码分析学习,欢迎有兴趣的同学可以来听听
- 素描
- CodeForces 479C Exams 贪心