Question: http://acm.hit.edu.cn/hoj/problem/view? Id = 1008
Reference: http://hujianliu-tuo.blog.163.com/blog/#m=0&t=1&c=fks_087068085080081075083080083095085086087069086095086069086
This question seems very simple. I tried to test all the numbers one by one. But when I did it, I found that I do not know the value range of K, in addition, if a timeout occurs during the process, you can avoid these problems only after referring to the code linked above. First, if the remainder of a number divided by the divisor can be divisible after the change, then the number can be divisible. Second, if the remainder is not divisible, an infinite loop occurs, so when the Division times reach a certain value, if the division is not completed, it indicates a loop. How big is it? It is also a good choice than yourself. However, it is surprising that some people's Code only ran for a few seconds ~ I can't think of anything in the future. I need to analyze it more. In many cases, it can be solved without violence.
# Include <iostream> using namespace STD; int main () {int n, m; while (CIN> N> m) {int num = N, Count = 1; while (Num % m! = 0) & (count <= 2 * m) {num = 10 * (Num % m) + N; count ++ ;} if (COUNT = 2 * m + 1) Count = 0; cout <count <Endl;} return 0 ;}