poj1426 Find The Multiple (DFS)
Time Limit: 1000MS | Memory Limit: 10000K | |||
Total Submissions: 41845 | Accepted: 17564 | Special Judge |
Description
Input
Output
Sample Input
2
6
19
0
Sample Output
10
100100100100100100
111111111111111111
Source
#include<iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod=;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
//head
#define MAX 1000
int n;
int flag;
void dfs(int cur,ll sum)
{
if(cur==)return ;
if(flag) return ;
if(sum%n==&&sum!=)
{
flag=;
cout<<sum<<endl;
return ;
}
else
dfs(cur+,sum*),dfs(cur+,sum*+);
}
int main()
{
cin.tie();
cout.tie();
ios::sync_with_stdio();
while(cin>>n)
{
if(n==)break;
flag=;
dfs(,);
}
return ;
}
poj1426 Find The Multiple (DFS)的更多相关文章
- POJ1426——Find The Multiple
POJ1426--Find The Multiple Description Given a positive integer n, write a program to find out a non ...
- poj1426 Find The Multiple(c语言巧解)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36335 Accepted: 151 ...
- POJ-2356 Find a multiple(DFS,抽屉原理)
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7133 Accepted: 3122 Speci ...
- POJ1426 Find The Multiple (宽搜思想)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24768 Accepted: 102 ...
- poj1426 Find The Multiple
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14622 Accepted: 593 ...
- POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)
http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find out a ...
- POJ1426 Find The Multiple —— BFS
题目链接:http://poj.org/problem?id=1426 Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Tota ...
- [POJ]Find The Multiple(DFS)
题目链接 http://poj.org/problem?id=1426 题意 输入一个数n,输出任意一个 只含0.1且能被n整除的数m.保证n<=200,m最多100位. 题解 DFS/BFS都 ...
- POJ1426——Find The Multiple (简单搜索+取余)
题意: 给一个数n,让你找出一个只有1,0,组成的十进制数,要求是找到的数可以被n整除. 用DFS是搜索 当前位数字 (除最高位固定为1),因为每一位都只有0或1两种选择,换而言之是一个双入口BFS. ...
随机推荐
- JavaScript原型&原型链
原型&原型对象 先来一段简单的代码: function Fun(name) { this.name = name } var obj = new Fun('obj') JavaScript中的 ...
- php pdo_mysql扩展安装
本文内容是以 CentOS 为例,红帽系列的 Linux 方法应该都是如此,下面就详细说明步骤,在这里严重鄙视哪些内容??隆⑺档脑悠咴影说挠泄 PDO 编译安装的文章. 1.进入 PHP 的软件包 p ...
- Sass--传多个参数
Sass 混合宏除了能传一个参数之外,还可以传多个参数,如: @mixin center($width, $height) { width: $width; height: $height; posi ...
- Echarts 自定义数据视图
toolbox : { show : true, feature : { dataView : { optionToContent : function(option) { // 行名称 var ax ...
- Flutter中的日期、格式化日期、日期选择器组件
Flutter中的日期和时间戳 //獲取當前日期 DateTime _nowDate = DateTime.now(); print(_nowDate);//2019-10-29 10:57:20.3 ...
- Java中的heap和stack
heap和stack Java的内存分为两类,一类是栈内存,一类是堆内存. 栈内存:是指程序进入一个方法时,会为这个方法单独分配一块私属存储空间,用于存储这个方法内部的局部变量,当这个方法结束时,分配 ...
- 【Http2.0】Http2.0
序言 目前HTTP/2.0(简称h2)已经在广泛使用(截止2018年8月根据Alexa流行度排名的头部1千万网站中,h2占比约29%,https://w3techs.com/technologies/ ...
- django+nginx+uwsgi_cent0s7.4 部署
django+nginx+uwsgi_cent0s7.4 部署 几条命令 # 查看是否有 uwsgi 相关的进程 ps -aux|grep "uwsgi" # 杀死有关 uwsgi ...
- 写出高性能SQL语句的十三条法则
1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的,比如一条SQL语句如果用来从一个10万条记录的表中查1条记 ...
- 各大漏洞平台及SRC的区别和如何批量刷漏洞
批量刷漏洞: 01刷指纹->02刷原始漏洞->03刷CMS->04刷指定政府.教育->05刷众测平台->06刷SRC->07刷国内外.活动 搜索引擎: 百度.goo ...