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. ...
随机推荐
- harbar仓库的接口测试
一.接口测试命令 api接口文档:https://github.com/goharbor/harbor/blob/release-1.7.0/docs/swagger.yaml 1)查看所属项目的信息 ...
- 开源安全:PE分析
https://github.com/JusticeRage/Manalyze.git https://github.com/JusticeRage/Manalyze https://www.free ...
- 【LeetCode】贪心 greedy(共38题)
[44]Wildcard Matching [45]Jump Game II (2018年11月28日,算法群衍生题) 题目背景和 55 一样的,问我能到达最后一个index的话,最少走几步. 题解: ...
- bzoj4145 [AMPPZ2014]The Prices 状压 DP
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=4145 题解 好像这道题有不少方法呢. ...谁叫这道题有点简单,所以方法多呗. 我的方法: 求 ...
- call_user_func_array — 调用回调函数,并把一个数组参数作为回调函数的参数
<?php function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2\n"; } clas ...
- Ubuntu12.04安装配置x11vnc
全程在root下进行 安装x11vnc sudo apt-get install vino vinagre x11vnc 设置密码 sudo x11vnc -storepasswd sudo x11v ...
- Jenkins服务配置容易忽略的事项
git客户端必须安装(可直接yum安装) maven安装的版本(Jenkins上用其插件较稳健,亲测maven3.5是坑) settings.xml文件必要时,指定对应路径(一般选用Jenkins默认 ...
- nyoj 600:花儿朵朵(树状数组+坐标离散化)
http://acm.nyist.net/JudgeOnline/problem.php?pid=600 只附代码好了 #include<bits/stdc++.h> using name ...
- Spring框架之接口实现覆盖(接口功能扩展)
在日常开发中,存在着这种一种场景,框架对接口A提供了一个种默认的实现AImpl,随着需求的变更,现今AImpl不能满足了功能需要,这时,我们该怎么办? 当然是修改AImpl的实现代码了,但是,如果它是 ...
- 抽象abstract
1):一个类如果有抽象方法,这个类一定是抽象类.抽象类不一定有抽象方法.抽象方法是以分号结束.不是以{}. 抽象方法也不提供实现代码. 2):任何拓展抽象类的类都必须实现超类的所有抽象方法.除非子类也 ...