POJ 1426 Find The Multiple

来源:互联网 发布:淘宝卖家诈骗800 编辑:程序博客网 时间:2024/06/05 20:31
http://poj.org/problem?id=1426
Find The Multiple
Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 19337Accepted: 7845Special 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

26190

Sample Output

10100100100100100100111111111111111111

Source

Dhaka 2002
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;

bool cmp(int a,int b)
{
return a>b;
}
int n;
void bfs()
{
queue<ll>q;
q.push(1);
while(!q.empty())
{
ll k=q.front();q.pop();
if(k%n==0)
{
printf("%I64d\n",k);break;
}
q.push(k*10);
q.push(k*10+1);
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
while(scanf("%d",&n)!=EOF)
{
if(n==0)break;
bfs();
}
return 0;
}
竟然没有超long long
0 0
原创粉丝点击