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# zxing生成二维码和打印

    生成二维码代码 asset=“要生成的字符串”: public static Bitmap CreateQRCode(string asset) { EncodingOptions options = ...

  2. Python - 列联表的独立性检验(卡方检验)

    Python - 列联表的独立性检验(卡方检验) 想对两个或两个以上因子彼此之间是否相互独立做检验时,就要用到卡方检验,原以为在Python中实现会像R的chisq.test一样简便,但scipy的s ...

  3. 微信小程序生成海报分享:canvas绘制文字溢出如何换行

    主要思路: 1.先分割为字符串数组,然后一个字一个字绘图,利用ctx.measureText(string) 方法,获取绘制后的宽度,判断宽度在多少内就另起一行,再将各行拼成一个字符串 2.计算另起的 ...

  4. Skyline中加载WMTS地图

    Skyline中默认是Bing地图,必应虽然免费无偏移,但在国内的影像质量并不是很好.不用担心,Skyline支持多种影像图层,包括WFS.WMS.WMTS地图服务.使用地图作为底图有两个好处: (1 ...

  5. 找回停掉docker的文件

    如果容器还能重启,就restart, 如果状态是DEAD的话, Error response from daemon: Container is marked for removal and cann ...

  6. 用于Spring Boot Jar部署的shell脚本

    用于在Jenkins将jar发送到目标节点之后的部署操作, 包含deploy, start, stop, restart功能. 在deploy时会自动备份原jar至指定目录 # Please defi ...

  7. 时间序列异常检测算法S-H-ESD

    1. 基于统计的异常检测 Grubbs' Test Grubbs' Test为一种假设检验的方法,常被用来检验服从正太分布的单变量数据集(univariate data set)\(Y\) 中的单个异 ...

  8. 星云STS 常用配置

    STS4  下载地址:https://spring.io/tools    (这个版本没有tomcat插件) STS3  下载地址:https://spring.io/tools3/sts/all ( ...

  9. Redis 分布式锁的实现

    0X00 测试环境 CentOS 6.6 + Redis 3.2.10 + PHP 7.0.7(+ phpredis 4.1.0) [root@localhost ~]# cat /etc/issue ...

  10. (9) MySQL主主复制架构使用方法

    一. 回忆主从复制的一些缺点 上节说到主从复制的一些问题 我们再来回忆一下 主从复制,增加了一个数据库副本,从数据库和主数据库的数据最终会是一致的 之所以说是最终一致,因为mysql复制是异步的,正常 ...