Find The Multiple--POJ1426
Description
Input
Output
Sample Input
2
6
19
0
Sample Output
10
100100100100100100
111111111111111111 题意是求出n任意一个倍数而这个数是只有0和1构成的十进制整数,输出任意符合题意的答案即可;
我们可以输出最小的符合条件的;这个数第一位一定为1;接着判断10,11,101,100,110,111......;可以用bfs来写; 代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
__int64 bfs(int n)
{
queue<__int64>Q;
Q.push();
long long q;
while(!Q.empty())
{
q=Q.front();
Q.pop();
if(q%n==)
return q;
Q.push(q*);
Q.push(q*+);
}
return -;
} int main()
{
int n;
__int64 ans;
while(scanf("%d",&n),n)
{
ans=bfs(n);
printf("%I64d\n",ans);
}
return ;
}
Find The Multiple--POJ1426的更多相关文章
- Find the Multiple POJ-1426
题目链接:Find the Multiple 题目大意 找出一个只由0和1组成的能整除n的数. 思路 所有由0和1组成的数可以看作是某个只由0.1组成的数a经过以下两种变化得到 1.a * 10 2. ...
- 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 (宽搜思想)
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 ...
- Find The Multiple (poj1426 一个好的做法)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16505 Accepted: 673 ...
- poj1426 Find The Multiple(c语言巧解)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36335 Accepted: 151 ...
- 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 ...
- 【POJ1426】Find The Multiple
本题传送门 本题知识点:深度优先搜索 | 宽度优先搜索 题意很简单,让我们找一个只有1和0组成的十位数是n的倍数的数. 这题一开始吓到我了--因为Output里说输出的长度最长不超过100位???那是 ...
- poj1426 Find The Multiple (DFS)
题目: Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41845 Accepted: ...
随机推荐
- linux 信息收集脚本。转自insight-labs
找出所有.sh .pl .py .conf .cnf .ini .*history .*pass* (/usr/share目录里面的除外) 并且在当前目录zip打包.有些时候很多配置文件的权限配置不严 ...
- Nginx 过期时间
客户端(浏览器)访问服务器上的资源后,会缓存在浏览器中,对于一些经常变更的静态资源,我们可以设置缓存时间,也就是设置静态资源的过期时间 [root@localhost ~]$ cat /usr/loc ...
- 计算直线与WGS84椭球的交点
/************************************************************************/ /*线段与WGS84椭球求交 x^2/a^2+y^ ...
- FTP文件下载
using EnterpriseDT.Net.Ftp; /// <summary> /// 下载FTP文件 /// </summary> /// <param name= ...
- 《转载》Eclipse项目上传码云
本文转载自http://blog.csdn.net/izzyliao/article/details/53074452 把Eclipse项目上传到码云的步骤: 1.登录码云:新建项目 2.输入项目名: ...
- 从Eclipse转移到IntelliJ IDEA的一点心得
IntelliJ使用指南—— 深入理解IntelliJ的Web部署逻辑 Intellij IDEA 部署Web项目,解决 404 错误 Intellij IDEA快捷键的使用 本文转载地址 本人使用I ...
- Qt——文件对话框
教程:https://www.devbean.net/2012/09/qt-study-road-2-file-dialog/ 代码如下: //mainwindow.h #ifndef MAINWIN ...
- Android应用的自动升级、更新模块的实现(转)
我们看到很多Android应用都具有自动更新功能,用户一键就可以完成软件的升级更新.得益于Android系统的软件包管理和安装机制,这一功能实现起来相当简单,下面我们就来实践一下.首先给出界面效果: ...
- echarts - 树图实现四个层级
我相信很多人和我一样,制作echats图标时,都会先去demo官网找相同的或者近似的效果,然后再此基础上改进成我们想要的那个. 但是近期混迹某微信群时,我看到一个群友抛出问题说,echarts画树状图 ...
- 安装cnpm
使用淘宝镜像的cnpm $ npm install -g cnpm --registry=https://registry.npm.taobao.org