POJ 1426 Find the multiple (find multiple)

Source: Internet
Author: User

poj 1426 Find the multiple (find multiple)

Time Limit: 1000MS Memory Limit: 65536K

description   -topic description

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

Given an integer n, a code is struck to find that only the numbers 0 and 1 of n are not 0 times times the number of M. You can assume that n does not exceed 200 and m does not exceed 100 decimal digits.
CN

input  -  enter

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.

Multiple sets of test cases. Each row has a number n (1). A line of one 0 ends for the input.
CN

Output-Outputs

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 digits. If There is multiple solutions for a given value of N, any one of the them is acceptable.

For each input n, the output is a row of M. The decimal number M must not exceed 100 bits. If there is more than one solution for n, then the output is random.
CN

Sample Input-Enter sample

26190

Sample output-export example

10100100100100100100111111111111111111

Exercises

Just started thinking straight 2^100 might be a bit of a problem, going to simulate division to do ... However, the level is too slag, writing conditions really desperate. (although it is possible to produce results but not to take into account the length of the problem when backtracking/transferring ...) )
Found that the discussion can be directly violent out ... And then find out ..... How can I?!
(estimated data not much)
Starting from 100 bits, it is possible to cut to 19-bit, int64 range.
However, it seems that due to the compiler's support for automatic conversion, the submission of the time to manually fix int64 can be.

Code C + +

1#include <cstdio>2 __int64 Isfid, N;3 voidDFS (__int64 Now,intLen) {4     if(!isfid | | len > -)return;5     if(Isfid = now%N) {6DFS (now *Ten, Len +1); DFS (now *Ten+1, Len +1);7     }8     Elseprintf"%i64d\n", now);9 }Ten intMain () { One      while(SCANF ("%i64d", &n), Isfid = N) DFS (1,0); A     return 0; -}

POJ 1426 Find the multiple (find multiple)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.