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 ...
随机推荐
- Redis 3.0.0 正式版出炉,高性能 K/V 服务
Redis 3.0.0 正式版最终到来了,与 RC6 版本号比較.该版本号改进包含: * 修复了无磁盘的复制问题 (Oran Agra) * 在角色变化后对 BLPOP 复制进行測试 (Salvato ...
- 【树状数组】POJ 2155 Matrix
附一篇经典翻译,学习 树状数组 http://www.hawstein.com/posts/binary-indexed-trees.html /** * @author johnsondu * @ ...
- android开发之使用SQLite数据库(db文件)
在开发中,有时须要使用db文件数据库.所以就须要将其导入项目,再将其使用程序写入到应用的db文件下使用. 代码非常easy.能够拿来直接使用. 要使用须要两个步骤: 1.创建raw文件.导入db文件. ...
- tolua reference
Using Lua API and tag method facilities, tolua maps C/C++ constants, external variables, functions, ...
- Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈
D. Vasya and Chess Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...
- visual studio2013 C++查看对象布局
一在visual studio中进行设置,可以方便的查看对象的内存布局 右键所要显示的*.cpp >> 属性 >> 命令行 >> 其它选项 在其他选项中添加: /d ...
- P1228 地毯填补问题(分治)
P1228 地毯填补问题(分治) 题目描述 相传在一个古老的阿拉伯国家里,有一座宫殿.宫殿里有个四四方方的格子迷宫,国王选择驸马的方法非常特殊,也非常简单:公主就站在其中一个方格子上,只要谁能用地毯将 ...
- 两个向量的outer product
#include <functional> template <class T1, class T2, class T3>void outer_product(std::vec ...
- yii 面包屑
Yii的Breadcrumbs 是Yii的路径插件,使用方法: <?php $this->widget('zii.widgets.CBreadcrumbs', array('links'= ...
- 网易UI自动化测试工具Airtest中导入air文件中的方法
最近看了一下网易的Airtest ,UI测试工具,写了一些后在导入其他air文件中的.py文件,卡了一下,现在博客中纪录一下导入其他air文件的方式: 在Airtest 测试工具中,导入其他air文件 ...