codeforces 244B-Undoubtedly Lucky Numbers 搜索
题意:给你一个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 搜索的更多相关文章
- codeforces 630C Lucky Numbers
C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...
- codeforces 630C - Lucky Numbers 递推思路
630C - Lucky Numbers 题目大意: 给定数字位数,且这个数字只能由7和8组成,问有多少种组合的可能性 思路: 假设为1位,只有7和8:两位的时候,除了77,78,87,88之外还哇哦 ...
- 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 ...
- 「CF630C」Lucky Numbers
更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description The numbers of all offices in the new ...
- [codeforces 55]D. Beautiful numbers
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...
- HDU 5676 ztr loves lucky numbers (模拟)
ztr loves lucky numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/I Description ztr ...
- hdu 5676 ztr loves lucky numbers(dfs+离线)
Problem Description ztr loves lucky numbers. Everybody knows that positive integers are lucky if the ...
- hdu 5676 ztr loves lucky numbers 打表+二分
ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- ZCMU 2177 Lucky Numbers (easy)
传送门: http://acm.zcmu.edu.cn/JudgeOnline/problem.php?id=2177 2177: Lucky Numbers (easy) 时间限制: 2 Sec ...
随机推荐
- 使用Keras编写GAN的入门
使用Keras编写GAN的入门 GAN Time: 2017-5-31 前言 代码 reference 前言 主要参考了网页[1]的教程,同时主要算法来自Ian J. Goodfellow 的论文,算 ...
- [Algorithms] The Bayes Rule
Prior odd: The idea is to take the odds for something happening (against it not happening), which we ...
- C++ 移位运算与进制转换 浅析
移位运算包括"逻辑移位"(logical shift)和"算术移位"(arithmetic shift). 逻辑移位:移出去的位丢弃,空缺位(vacant bi ...
- oc32--构造方法1
// // Person.h #import <Foundation/Foundation.h> @interface Person : NSObject @property int ag ...
- 查看tensorflow pb模型文件的节点信息
查看tensorflow pb模型文件的节点信息: import tensorflow as tf with tf.Session() as sess: with open('./quantized_ ...
- [SDOI2007]游戏
https://zybuluo.com/ysner/note/1184420 题面 题意简单,但不太好概括. 戳我 解析 不成熟想法 据题意可知,字符串字符的顺序无影响. 并且判断两个字符串能否接龙可 ...
- category中添加属性的简单方式
一.概念扩充: 1.如我们所知,使用category是用来对现有类进行功能扩展,或者将类分成多模块的一种方式.由声明和实现两部分组成.可以单独写成Objiective-C File类型文件(包含.h和 ...
- php 关于使用七牛云存储
1.首先注册七牛云存储账号 http://www.qiniu.com/ 2.获得密钥 3.仔细查看文档 http://developer.qiniu.com/docs/v6/sdk/php-sdk.h ...
- oen /var/run/nginx.pid failed
nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory) [root@TES ...
- C#三种创建对象方法所需时间比较。。。。。
C#创建对象的三种方法 new().Activator.Assembly,接下来通过代码直接来看看运行的速度.... 首先,先看看三种创建对象实例的方法: //new(); public stati ...