题意:给你一个n,求不大于n的并且仅由两种或者一种数字组成的数的个数。(有点绕,,简单点就是,看看小于等于n点数中,,有多少数字只有一种数字,或者有两种数字组成)

“哎,自己还是太菜了,训练的时候只做出来了一个水题,自闭中.....”

思维题刷的太少了,做题的时候总是想不到。

思路呢就是  两个循环,遍历两个数字的组合,然后宝搜就好了;

哎,不说了,说多了都是泪,见代码吧;

 #include <iostream>
#include <cstdio>
#include <set>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
int a[maxn];
set<ll>ss;
void dfs(int x,int y,int n,ll s,int cnt)
{
if(s>n||(s==&&cnt>))return;
if(s>)ss.insert(s);
dfs(x,y,n,s*+x,cnt+);
dfs(x,y,n,s*+y,cnt+);
}
int main()
{
int n;
cin>>n;
for(int i=;i<=;i++)
for(int j=i+;j<=;j++)
dfs(i,j,n,,);
cout<<ss.size()<<endl;
return ;
}

codeforces 244B-Undoubtedly Lucky Numbers 搜索的更多相关文章

  1. codeforces 630C Lucky Numbers

    C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...

  2. codeforces 630C - Lucky Numbers 递推思路

    630C - Lucky Numbers 题目大意: 给定数字位数,且这个数字只能由7和8组成,问有多少种组合的可能性 思路: 假设为1位,只有7和8:两位的时候,除了77,78,87,88之外还哇哦 ...

  3. Codeforces Round #160 (Div. 2)---A. Roma and Lucky Numbers

    Roma and Lucky Numbers time limit per test 1 second memory limit per test 256 megabytes input standa ...

  4. 「CF630C」Lucky Numbers

    更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description The numbers of all offices in the new ...

  5. [codeforces 55]D. Beautiful numbers

    [codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...

  6. HDU 5676 ztr loves lucky numbers (模拟)

    ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...

  7. hdu 5676 ztr loves lucky numbers(dfs+离线)

    Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...

  8. hdu 5676 ztr loves lucky numbers 打表+二分

    ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  9. ZCMU 2177 Lucky Numbers (easy)

    传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec   ...

随机推荐

  1. HDU 4363

    这题是记忆化搜索很容易想到,但状态却不好设 dp[i][j][u][d][l][r][k].对于矩形为i*j,它的四周的颜色分别为u,d,l,r,横竖切的状态为k的种数. 其中要注意一个问题是,停止不 ...

  2. 通过telent、php深入了解http协议

    HTTP协议:简单点就是client怎么问.server如何答. 重要性:webservice 还是rest做大型架构都离不开对http协议的认识,甚至能够简化的说webservice =  http ...

  3. 改动mysqlpassword

    1.假设没有password,则 mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass'); ...

  4. Centos7安装Rancher

    docker pull rancher/server:v1.6.14 启动一个单实例的Rancher. docker run -d --restart=unless-stopped -p 8080:8 ...

  5. hdu 1429(BFS+状态压缩)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  6. 【POJ 1456】 Supermarket

    [题目链接] http://poj.org/problem?id=1456 [算法] 贪心 + 堆 [代码] #include <algorithm> #include <bitse ...

  7. jFinal基于maven简单的demo

    JFinal 是基于Java 语言的极速 web 开发框架,其核心设计目标是开发迅速.代码量少.学习简单.功能强大.轻量级.易扩展.Restful.在拥有Java语言所有优势的同时再拥有ruby.py ...

  8. CentOS7 搭建Kafka(三)工具篇

    CentOS7 搭建Kafka(三)工具篇 做为一名懒人,自然不喜欢敲那些命令,一个是容易出错,另外一个是懒得记,能有个工具就最好了,一查还挺多,我们用个最主流的Kafka Manager Kafka ...

  9. Spring Boot (10) mybatis三种动态sql

    脚本SQL xml配置方式见mybatis讲解,下面是用<script>的方式把它照搬过来,用注解来实现.适于xml配置转换到注解配置 @Select("<script&g ...

  10. supervisord 使用记录

    #supervisor简介 Supervisor是一个 Python 开发的 client/server 系统,可以管理和监控类 UNIX 操作系统上面的进程. #组成部分 supervisord(s ...