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)