牛客提高D2t2 幸运数字考试
分析
预处理出所有合法数字
然后直接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 幸运数字考试的更多相关文章
- 牛客练习赛13D 幸运数字4
题目链接:https://ac.nowcoder.com/acm/contest/70/D 题目大意: 略 分析: 注意到12! < 10^9 < 13!,于是当n > 13时,第k ...
- 牛客练习赛13B 幸运数字2
题目链接:https://ac.nowcoder.com/acm/contest/70/B 题目大意: 略 分析: 先DFS求出所有幸运数,然后暴力即可 代码如下: #pragma GCC optim ...
- 牛客提高集训营6 C 树(树链剖分)
题目链接 为了纪(zhuang)念(bi)写完这个树剖单独写一篇.感觉还好,也就6k嘛. 完整比赛题解:https://www.cnblogs.com/SovietPower/p/9826829.ht ...
- 牛客提高R5 A.同余方程
题意 题目链接 Sol 设\(solve(x, y)\)表示\(i \in [0, x], j \in [0, y]\)满足题目要求的方案数 首先容斥一下,\(ans = solve(r_1, r_2 ...
- 牛客提高D6t3 分班问题
分析 就就就是推柿子 看官方题解吧/px 代码 #include<iostream> #include<cstdio> #include<cstring> #inc ...
- 牛客提高D6t2 破碎的序列
分析 我们不难发现对于偶数的情况只要相邻两个数不相等即可 而对于奇数的情况只要中间恰好隔一个数的两个数不相等即可 于是我们又dp[i][0/1]表示考虑到第i位,这一位和它后面离它最近的一个确定的数是 ...
- 牛客提高D6t1 积木大赛
分析 每次修改用二位差分记录一下 之后对于三维分别统计即可 代码 #include<iostream> #include<cstdio> #include<cstring ...
- 牛客提高D5t1 deco的abs
分析 傻子题? 对d取模后随便贪心即可 代码 #include<iostream> #include<cstdio> #include<cstring> #incl ...
- 牛客提高D4t3 清新题
分析 树上从下往上线性基合并即可 并不需要启发式/xyx 代码 #include<iostream> #include<cstdio> #include<cstring& ...
随机推荐
- oracle--角色权限
将不同权限赋予角色,再将角色赋予用户,起到管理权限的作用 SQL> create role myrole; 角色已创建. SQL> grant create session to myro ...
- 000 (H5*) 知识点总结
https://note.youdao.com/ynoteshare1/index.html?id=ff02e616917fba868f39241c8383d7c7&type=note 目录 ...
- 如何将.Net Core应用程序部署在Linux操作系统上运行
.Net Core简介 跨平台: 可以在 Windows.macOS 和 Linux 操作系统上运行. 跨体系结构保持一致: 在多个体系结构(包括 x64.x86 和 ARM)上以相同的行为运行代码. ...
- js获取指定字符后面的字符
function getCaption(obj){ var index=obj.lastIndexOf("\-"); obj=obj.substring(index+1,obj.l ...
- Hadoop运行模式:本地模式、伪分布模式、完全分布模式
1.本地模式:默认模式 - 不对配置文件进行修改. - 使用本地文件系统,而不是分布式文件系统. - Hadoop不会启动NameNode.DataNode.ResourceManager.NodeM ...
- nginx 499错误
原因: 服务响应时间太长,客户端自动断开链接. 解决: 1. 找到响应世间长的接口,看依赖的数据源(数据库,第三方接口等)响应时间是否超时,还是自己程序有逻辑问题. 可以通过加入日志打印时间消耗来确定 ...
- VS2015+QT环境配置后,Lauch Qt Designer打开失败,无法打开*.ui文件
最近在VS2015上配置QT时出现了这个问题,遂百度其解决方法,解决之后记录下来.第一步: 在[解决方案资源管理器]中,右击你的 xxx.ui文件,选择[打开方式],此时列表中默认值是[ Qt des ...
- Codeforces 833B 题解(DP+线段树)
题面 传送门:http://codeforces.com/problemset/problem/833/B B. The Bakery time limit per test2.5 seconds m ...
- 使用pdfobject.js实现在线浏览PDF
1.pdfobject.js官网:https://pdfobject.com/ 2.在html文件中引入这个文件,以pdfobject.min.js为例 <script type="t ...
- .linux基础命令三
一. 两台服务器免密登录: 1. 生成密钥 ssh-keygen的命令手册,通过”man ssh-keygen“命令查看指令: 通过命令”ssh-keygen -t rsa“创建一对密匙,包括公匙和私 ...