Question Link
A student dreamed of walking in a street with many bars. He can have a drink at each bar. All bars have a positive integer number. This person can go from bar n to the bar where the number can be divided by N. Now he wants to go from bar a to bar B. How much wine can he have at most.
Idea: Because B must be a multiple of A, which is multiplied by a from the beginning. In fact, it is to find the prime division that constitutes B/, the number of prime numbers that you can drink.
1 # include <stdio. h> 2 # include <string. h> 3 # include <iostream> 4 5 using namespace STD; 6 7 int sumnum (int n) 8 {9 for (INT I = 2; I * I <= N; I ++) // The Prime Number 10 {11 if (N % I = 0) {// if it is 0, one more, then, find 12 return 1 + sumnum (N/I); 13} 14} 15 return 0; 16} 17 int main () 18 {19 int T; 20 scanf ("% d", & T); 21 int A, B; 22 while (t --) 23 {24 scanf ("% d", &, & B); 25 if (B %! = 0) 26 {27 printf ("0 \ n"); 28 continue; 29} 30 else if (a = B) 31 {32 printf ("1 \ n"); 33 continue; 34} 35 int ans = sumnum (B/A); 36 printf ("% d \ n ", ans + 2); // Add a and B37} 38 return 0; 39}
View code
Ural 1355. Bald spot Revisited (number theory)