Test instructions: Some numbers can be like this: ABCD*K=DABC, for example, 179487 * 4 = 717948, just move the mantissa 7 to the front, without changing the position and size. Here will give 3 numbers B, D, K, respectively, representing the B-system, the mantissa, the 2nd multiplier. Since it is the mantissa, there must be d<b. There are several numbers for this abc...d (by B-in).
Idea: For example, the binary is 10, Assuming that the number is 6 bits, then abcdef represents the 6 digits, F has been given, is 7, and the other multiplier is 4. Because ABCDE7*4=7ABCDE.
(1) Push e:4*7=28, then E must be 8.
(2) Push d:abcd87*4=abcd8, remove unnecessary things continue to calculate, ABCD8*4=ABCD, then 4*8=32, but also add 1th step in the left 2,32+2=34, then D is certainly 4;
(3) Push c:abc487*4=abc48, remove redundancy, ABC4*4=ABC, then 4*4=16+3=19, then C is 9.
(4) and so on until a=7.
This is assumed to be a 6-bit, because I already know the answer, we can not have to assume that there are several, only need to push down until the last number on the line (test instructions to D), and no carry. The Carry-on is also required to continue until the rounding is 0.
1#include <bits/stdc++.h>2 #defineLL Long Long3 using namespacestd;4 intA, B, C;5 intMain ()6 {7 //freopen ("Input.txt", "R", stdin);8 while(~SCANF ("%d%d%d",&a,&b,&c))9 {Ten intE=b; One intf=0; A intCnt=1; - intg=0; - while(1) the { -G=e*c+f;//Total Results -e=g%a;//E is the last one for each calculation -f=g/a;//F is the number that requires rounding + if(g==b)//equals beginning - { +printf"%d\n", CNT); A Break; at } -cnt++; - } - } - return 0; -}
AC Code
UVA 550 multiplying by Rotation (simple recursion)