分析

预处理出所有合法数字

然后直接lower_bound查询即可

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define int long long
char s[];
int n,m,t,cnt,d[];
inline void dfs(int sum4,int sum7,int len,int wh){
if(sum4==len&&sum7==len){
d[++cnt]=wh;
return;
}
if(sum4<len)dfs(sum4+,sum7,len,wh*+);
if(sum7<len)dfs(sum4,sum7+,len,wh*+);
return;
}
signed main(){
int i,j,k;
for(i=;i<=;i++)dfs(,,i,);
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
if(n>d[cnt]){
puts("");
}else {
k=lower_bound(d+,d+cnt+,n)-d;
printf("%lld\n",d[k]);
}
}
return ;
}

牛客提高D2t2 幸运数字考试的更多相关文章

  1. 牛客练习赛13D 幸运数字4

    题目链接:https://ac.nowcoder.com/acm/contest/70/D 题目大意: 略 分析: 注意到12! < 10^9 < 13!,于是当n > 13时,第k ...

  2. 牛客练习赛13B 幸运数字2

    题目链接:https://ac.nowcoder.com/acm/contest/70/B 题目大意: 略 分析: 先DFS求出所有幸运数,然后暴力即可 代码如下: #pragma GCC optim ...

  3. 牛客提高集训营6 C 树(树链剖分)

    题目链接 为了纪(zhuang)念(bi)写完这个树剖单独写一篇.感觉还好,也就6k嘛. 完整比赛题解:https://www.cnblogs.com/SovietPower/p/9826829.ht ...

  4. 牛客提高R5 A.同余方程

    题意 题目链接 Sol 设\(solve(x, y)\)表示\(i \in [0, x], j \in [0, y]\)满足题目要求的方案数 首先容斥一下,\(ans = solve(r_1, r_2 ...

  5. 牛客提高D6t3 分班问题

    分析 就就就是推柿子 看官方题解吧/px 代码 #include<iostream> #include<cstdio> #include<cstring> #inc ...

  6. 牛客提高D6t2 破碎的序列

    分析 我们不难发现对于偶数的情况只要相邻两个数不相等即可 而对于奇数的情况只要中间恰好隔一个数的两个数不相等即可 于是我们又dp[i][0/1]表示考虑到第i位,这一位和它后面离它最近的一个确定的数是 ...

  7. 牛客提高D6t1 积木大赛

    分析 每次修改用二位差分记录一下 之后对于三维分别统计即可 代码 #include<iostream> #include<cstdio> #include<cstring ...

  8. 牛客提高D5t1 deco的abs

    分析 傻子题? 对d取模后随便贪心即可 代码 #include<iostream> #include<cstdio> #include<cstring> #incl ...

  9. 牛客提高D4t3 清新题

    分析 树上从下往上线性基合并即可 并不需要启发式/xyx 代码 #include<iostream> #include<cstdio> #include<cstring& ...

随机推荐

  1. linux command --- terminal common commands

    switch to root : sudo su.su root.sudo -s switch to users : su god(user name) set root password : sud ...

  2. 欧拉函数&欧拉定理&降幂 总结

    欧拉函数&欧拉定理&降幂 总结 标签:数学方法--数论 阅读体验:https://zybuluo.com/Junlier/note/1300214 这年头不总结一下是真的容易忘,老了老 ...

  3. poj1011 Sticks (dfs剪枝)

    [题目描述] George took sticks of the same length and cut them randomly until all parts became at most 50 ...

  4. 把java(springboot)程序打包docker镜像

    前言:要在docker运行java(jar包)程序,就要把程序打包成docker镜像(以下简称镜像),可以先理解为镜像就是jar包 打包需要程序代码,java本身的打包环境(包括jdk和maven), ...

  5. 谈Apache OFbiz 会员模块表结构设计

    数据库表的结构设计可谓是ofbiz除技术框架之外,另一个非常值得学习的方向.这篇文章我们来谈谈ofbiz对电子商务会员表的设计. PARTY ofbiz对人.团体进行了抽象,称之为party,翻译为中 ...

  6. C#学习——控件

    Windows应用程序控件的基类是位于System.Windows.Forms命名空间的Control类. Control类定义了控件类的共同属性.方法和事件,其他的控件类都直接或间接到派生自这个类. ...

  7. Cannot change column 'id': used in a foreign key constraint

    原因:为表添加自增长,但由于该表有外键而报错 发现是因为外键的影响,不能随便的更改表结构. 要想更改表结构,首先要把基层的表修改了. A表 作为B表的外键,A表不能随便修改. B表 有A表的外键,必须 ...

  8. 类目(category) - 类扩展(extension) 区别

    说明: 方法,属性或变量:   类别只能添加方法,不能添加属性(理论上,但可以通过runtime的关联添加). 扩展可以添加方法和实例变量或属性,实例变量默认@private类型.扩展是类别的一个特例 ...

  9. MiniUI学习笔记1-表单控件

    1.输入框样式 class="mini-textbox" //普通输入框 class="mini-password" //密码输入框 class="m ...

  10. IPC之套接字

    IPC(Inter-Process Communication,进程间通信)实现方式 1)管道: - 管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程之间使用(进程的亲缘关系 ...