POJ1426——Find The Multiple
The Find multiple
2023-09-14 09:08:53 时间
POJ1426——Find The Multiple
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
代码:
#include<iostream>
#include<bits/stdc++.h>
#include<queue>
using namespace std;
void BFS(int x){
queue<int> q ;
q.push(1);
int y;
while (!q.empty())
{
y=q.front();
q.pop();
for (int i = 0; i < 2; i++)
{
if (i==0) q.push(y*10);
else
q.push(y*10+1);
if (y%x==0)
{
cout<<y<<endl;
return ;
}
}
}
}
int main(){
int x;
while ((cin>>x)&&x)
{
BFS(x);
}
}
相关文章
- spring-boot:The following method did not exist: com.google.gson.GsonBuilder.setLenient()
- 【踩坑实录】-java.sql.SQLException: The MySQL server is running with the LOCK_WRITE_GROWTH option so it ca
- S2 - Lesson 37 - The Olympic Games
- ORA-23368: name string cannot be null or the empty string ORACLE 报错 故障修复 远程处理
- ORA-26004: Tables loaded through the direct path may not be clustered ORACLE 报错 故障修复 远程处理
- ORA-27611: Smart I/O failed due to a block corruption detected on the host. The block was received from cell “string”. disk: “string”, block: “string”, disk offset: “string” ORACLE 报错 故障修复 远程处理
- ORA-28079: The policy was already enabled. ORACLE 报错 故障修复 远程处理
- ORA-28082: The parameter string is invalid. ORACLE 报错 故障修复 远程处理
- ORA-29297: The compressed representation is too big ORACLE 报错 故障修复 远程处理
- ORA-29863: warning in the execution of ODCIINDEXCREATE routine ORACLE 报错 故障修复 远程处理
- ORA-32342: The EXPLAIN_MVIEW facility failed to explain the materialized view statement ORACLE 报错 故障修复 远程处理
- ORA-38404: schema extension not allowed for the attribute set name ORACLE 报错 故障修复 远程处理
- ORA-48408: The incident number exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-48411: The trace files exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-48441: The function parameter number exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-48928: The predicate exceeds the max limit string ORACLE 报错 故障修复 远程处理
- ORA-53009: cannot find the tag value in the metadata schema ORACLE 报错 故障修复 远程处理
- ORA-53010: The value of the tag is null. ORACLE 报错 故障修复 远程处理
- ORA-55568: The maximum query length (mql) value should be atmost string based on the current _highthreshold_undoretention setting. ORACLE 报错 故障修复 远程处理
- ORA-12835: No instances are active in the GLOBAL_VIEW_ADMIN_GROUP ORACLE 报错 故障修复 远程处理
- ORA-13614: The template string is not compatible with the current advisor. ORACLE 报错 故障修复 远程处理
- ORA-14303: partitions or subpartitions are not in the right order ORACLE 报错 故障修复 远程处理
- ORA-16736: unable to find the destination entry of standby database “string” in V$ARCHIVE_DEST ORACLE 报错 故障修复 远程处理
- Linux: Driving the Future of Computing(linuxdone)
- Cairo: A New Level of Power in the Linux World(cairolinux)
- Linux的分支:Explore the Different Paths(linux的分支)
- 域渗透——Pass The Hash & Pass The Key
- Unleash the Power of Oracle DS: Transform Your Business Now(oracleds)
- Exploring the Benefits of Using Linux FAT File System: A Comprehensive Guide for Beginners(linuxfat)
- Exploring the Features and Benefits of MySQL 5.5(mysql5.5)
- Importing XML files into MySQL: The Complete Guide for Data Integration(xml文件导入mysql)