Find The Multiple
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 30659   Accepted: 12755   Special Judge

Description

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.

Input

The input file may contain multiple test cases. Each line contains a value of n (1 <= n <= 200). A line containing a zero terminates the input.

Output

For each value of n in the input print a line containing the corresponding value of m. The decimal representation of m must not contain more than 100 digits. If there are multiple solutions for a given value of n, any one of them is acceptable.

Sample Input

2
6
19
0

Sample Output

10
100100100100100100
111111111111111111

Source

打表。。。
 #include <iostream>
#include <cstdio>
#include <queue>
#include <cstring> using namespace std; struct node{
int mod;
char str[];
int cou;
}; char ans[][];
int i; void bfs(int n){
queue<node> que;
node t;
t.mod=;
t.cou=;
t.str[t.cou++]=''; que.push(t);
while(!que.empty()){
node now=que.front();
que.pop();
if(now.mod%n==){
now.str[now.cou]='\0';
//strcpy(ans[i],now.str);
printf("%s,",now.str);
return ;
}
node next=now;
next.mod=(now.mod*)%n;
next.str[next.cou++]='';
que.push(next);
next.mod=(now.mod*+)%n;
next.str[next.cou-]='';
que.push(next);
}
} int main()
{
int n;
for(i=;i<=;i++){
bfs(i);
} while(scanf("%d",&n)&&n!=){
printf("%s\n",ans[n]);
}
return ;
}
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue> using namespace std; long long a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
int main()
{
int n;
while(scanf("%d",&n)&&n!=){
printf("%lld\n",a[n]);
} return ;
}
 

poj1426_kuagnbin带你飞专题一的更多相关文章

  1. 【算法系列学习三】[kuangbin带你飞]专题二 搜索进阶 之 A-Eight 反向bfs打表和康拓展开

    [kuangbin带你飞]专题二 搜索进阶 之 A-Eight 这是一道经典的八数码问题.首先,简单介绍一下八数码问题: 八数码问题也称为九宫问题.在3×3的棋盘,摆有八个棋子,每个棋子上标有1至8的 ...

  2. [kuangbin带你飞]专题1-23题目清单总结

    [kuangbin带你飞]专题1-23 专题一 简单搜索 POJ 1321 棋盘问题POJ 2251 Dungeon MasterPOJ 3278 Catch That CowPOJ 3279 Fli ...

  3. [kuangbin带你飞]专题十 匹配问题

        A-L 二分匹配 M-O 二分图多重匹配 P-Q 二分图最大权匹配 R-S 一般图匹配带花树 模板请自己找     ID Origin Title   61 / 72 Problem A HD ...

  4. [kuangbin带你飞]专题十 匹配问题 一般图匹配

    过去做的都是二分图匹配 即 同一个集合里的点 互相不联通 但是如果延伸到一般图上去 求一个一般图的最大匹配 就要用带花树来解决 带花树模板 用来处理一个无向图上的最大匹配 看了一会还是不懂  抄了一遍 ...

  5. [kuangbin带你飞]专题十 匹配问题 二分匹配部分

    刚回到家 开了二分匹配专题 手握xyl模板 奋力写写写 终于写完了一群模板题 A hdu1045 对这个图进行 行列的重写 给每个位置赋予新的行列 使不能相互打到的位置 拥有不同的行与列 然后左行右列 ...

  6. [kuangbin带你飞]专题八 生成树 - 次小生成树部分

    百度了好多自学到了次小生成树 理解后其实也很简单 求最小生成树的办法目前遇到了两种 1 prim 记录下两点之间连线中的最长段 F[i][k] 之后枚举两点 若两点之间存在没有在最小生成树中的边 那么 ...

  7. [kuangbin带你飞]专题六 最小生成树

    学习最小生成树已经有一段时间了 做一些比较简单的题还算得心应手..花了三天的时间做完了kuangbin的专题 写一个题解出来记录一下(虽然几乎都是模板题) 做完的感想:有很多地方都要注意 n == 1 ...

  8. [kuangbin带你飞]专题十五 数位DP

            ID Origin Title   62 / 175 Problem A CodeForces 55D Beautiful numbers   30 / 84 Problem B HD ...

  9. [kuangbin带你飞]专题十 匹配问题 二分图多重匹配

    二分图的多重匹配问题不同于普通的最大匹配中的"每个点只能有最多一条边" 而是"每个点连接的边数不超过自己的限定数量" 最大匹配所解决的问题一般是"每个 ...

随机推荐

  1. C#隐藏手机号中间四位为*

    使用正则:Regex.Replace(手机号, "(\\d{3})\\d{4}(\\d{4})", "$1****$2"); 效果:

  2. python测试开发django-55.xadmin使用markdown文档编辑器(django-mdeditor)

    前言 markdown是一个非常好的编辑器,用过的都说好,如果搭建一个博客平台的话,需要在后台做文章编辑,可以整合一个markdown的文本编辑器. github上关于django的markdown插 ...

  3. iOS:检测多媒体(相机、相册、麦克风)设备权限,弹框提示

    一.感言 新年伊始,万象更新,一转眼,就2019年了. 作为一个科班生,从事移动端开发好几年了,回顾曾经的摸爬滚打,兢兢业业,严格的来说,多少算是入行了. 过去成绩如何暂且不说,新的一年,我当加倍努力 ...

  4. 为RecyclerView打造通用Adapter

    ##RecycleView简单介绍 RecyclerView控件和ListView的原理有非常多相似的地方,都是维护少量的View来进行显示大量的数据.只是RecyclerView控件比ListVie ...

  5. 每天一个linux命令(11):nl命令

    1.命令简介 nl (Number of Lines) 将指定的文件添加行号标注后写到标准输出.如果不指定文件或指定文件为"-" ,程序将从标准输入读取数据. 2.用法 nl [选 ...

  6. Docker 的插件式设计

    http://www.tuicool.com/articles/MnIRZvJ http://uzhima.com/2016/08/02/what-is-docker-volume-plugin/ 在 ...

  7. Visual Studio进行Web性能测试- Part I

    Visual Studio进行Web性能测试- Part I 2012-08-29 08:01 by 知平软件, 5356 阅读, 9 评论, 收藏, 编辑 原文作者:Ambily.raj Visua ...

  8. KADEMLIA算法

    一.概述 基于异或距离算法的分布式散列表(DHT), 实现了去中心化的信息存储于查询系统: Kademlia将网络设计为具有160层的二叉树,树最末端的每个叶子看作为节点,节点在树中的位置由同样是16 ...

  9. MyBatis3 入门学习指南

    官网原文:http://www.mybatis.org/mybatis-3/zh/index.html 1.简介 1.1 什么是 MyBatis? MyBatis 是一款优秀的持久层框架,它支持定制化 ...

  10. [k8s] flexvolume workflow