题意:给你一个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. PHP array_intersect_assoc()

    定义和用法 array_intersect_assoc() 函数返回两个或多个数组的交集数组. 与 array_intersect() 函数 不同的是,本函数除了比较键值,还比较键名.返回的数组中元素 ...

  2. spring 计时器

    spring 计时器 可以这样: http://blog.csdn.net/u010648555/article/details/52162840 也可以使用annotation <!-- 设置 ...

  3. 《Android源代码设计模式解析与实战》读书笔记(十八)

    第十八章.代理模式 代理模式也称托付模式,是结构型设计模式之中的一个.是应用广泛的模式之中的一个. 1.定义 为其它对象提供一种代理以控制对这个对象的訪问. 2.使用场景 当无法或不想直接訪问某个对象 ...

  4. URAL 1601. AntiCAPS (strings)

    1601. AntiCAPS Time limit: 0.5 second Memory limit: 64 MB The blonde Angela has a new whim: internet ...

  5. java中statickeyword

    1.static变量 依照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:还有一种是没有被static修饰的变量,叫实例变量. 两者的差别是: 对于静态变量 ...

  6. oc28--Property增强

    // // Person.h #import <Foundation/Foundation.h> @interface Person : NSObject /* { @public int ...

  7. PCB 生产周期计算逻辑与代码实现

    PCB生产周期计算逻辑: 代码实现: 调用代码: getWeek(DateTime.Now.Date, ); 周期计算逻辑: /// <summary> /// 获取周期 /// < ...

  8. golang——(strings包)常用字符串操作函数

    (1)func HasPrefix(s, prefix string) bool 判断字符串s是否有前缀字符串prefix: (2)func HasSuffix(s, suffix string) b ...

  9. JQuery+Bootstrap总结

    ================JQuery=========== JQuery 1. jQuery是什么? 一个js插件, 相比较原生的DOM操作更简单.开发效率更高 2. jQuery使用 1. ...

  10. BZOJ 4525 二分

    思路: 满足二分性质... 二分一下      就完了 //By SiriusRen #include <cstdio> #include <algorithm> using ...