题目传送门

 /*
DFS:按照长度来DFS,最后排序
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int b[] = {, };
int a[MAXN];
int tot; void DFS(int now, int l, int len)
{
if (l == len) {a[++tot] = now; return ;}
for (int i=; i<; ++i)
{
int tmp = now * + b[i];
DFS (tmp, l + , len);
}
} void solve(void)
{
tot = ;
for (int i=; i<=; ++i)
{
DFS (, , i);
}
sort (a+, a++tot);
//for (int i=1; i<=tot; ++i) printf ("%d ", a[i]);
} int main(void) //Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
{
solve ();
int n;
while (scanf ("%d", &n) == )
{
printf ("%d\n", lower_bound (a+, a++tot, n) - a);
} return ;
}

DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas的更多相关文章

  1. Codeforces Round #299 (Div. 2) B. Tavas and SaDDas【DFS/*进制思维/位运算/一个数为幸运数,当且仅当它的每一位要么是4,要么是7 ,求小于等于n的幸运数个数】

    B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题

    B. Tavas and SaDDas Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/p ...

  3. 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs

    题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...

  4. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  5. Codeforces Round #299 (Div. 2) D. Tavas and Malekas kmp

    题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...

  6. Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题

    Tavas and Karafs Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...

  7. Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题

    A. Tavas and Nafas Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...

  8. Codeforces Round #299 (Div. 1)C. Tavas and Pashmaks (凸壳)

    C. Tavas and Pashmaks   Tavas is a cheerleader in the new sports competition named "Pashmaks&qu ...

  9. Codeforces Round #299 (Div. 2)D. Tavas and Malekas

    KMP,先预处理按每个节点标记,扫一遍更新每个匹配位置,最后kmp判断是否有重合而且不相同的地方 注意处理细节,很容易runtime error #include<map> #includ ...

随机推荐

  1. 聊聊高并发(四十)解析java.util.concurrent各个组件(十六) ThreadPoolExecutor源代码分析

    ThreadPoolExecutor是Executor运行框架最重要的一个实现类.提供了线程池管理和任务管理是两个最主要的能力.这篇通过分析ThreadPoolExecutor的源代码来看看怎样设计和 ...

  2. JAVA_the user operation is waiting怎么办

    彻底解决 MyEclipse出现the user operation is waiting的问题   2011-05-31 10:32:30|  分类: 软件编程 |  标签:java  myecli ...

  3. Deepin-安装QQ音乐(Windows程序)

    打开命令行,输入: sudo apt-get install wine 安装完成后,下载QQ音乐的安装包 然后安装 示例:wine xx.exe 实例:wine QQMusic.exe 安装完成,启动 ...

  4. hdoj 5093 Battle ships 【二分图最大匹配】

    题目:pid=5093" target="_blank">hdoj 5093 Battle ships 题意:给你一个n*m的图,图中有冰山 '# ',浮冰 'o' ...

  5. Sql sever 分组排序

    维护人事的时候人事局要求加入一个新功能,详细需求例如以下:加入的人员在同一个单位的依照顺序编号而且单位也要实现时间排序,也就是说有两个排序,第一单位名称排序.先创建的一直在前.然后依照创建时间依次排序 ...

  6. Android经常使用设计模式(二)

    继上一篇 Android经常使用设计模式(一)里认识了观察者.适配器.代理等三种模式,这一篇将会解说下面三种模式: 工厂模式 单例模式 命令模式 1.工厂模式(Factory Pattern) 工厂模 ...

  7. POST 请求静态文件 响应405

    使用post方式请求js.html这样的静态文件一般的web服务器都会返回405 Method Not Allowed. 我测试用的web服务器用的是IIS(windows10+IIS10),理论上来 ...

  8. HttpClient服务端发送http请求

    本来以为对跨域问题的处理已经比较熟练了.可以通过jsonp.document.domain+iframe.window.name.window.postMessage.服务器上设置代理页面来解决.但还 ...

  9. V4L学习

    http://blog.csdn.net/wangrunmin/article/details/7764768# http://blog.sina.com.cn/s/blog_a44175a90101 ...

  10. 设置Table边框的CSS

    <!DOCTYPE html> <html> <head> <style> table, td, th { border: 1px solid blac ...