This is a mathematical question. The question is roughly to ask whether a certain number is "modest", that is, to satisfy all the factors from 2, 3, 5, 7. The data composed of the four qualitative factors then asks how many factors the number has;
Solution: Split the data, count the number of each prime factor, and then multiply them directly. As for why, read books related to number theory. Note that if the remainder statistics are obtained directly at the end, the remaining result is 1. Therefore, use a loop to determine whether n is 1 and if statements can also be used.
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<cmath> using namespace std; #define LL long long int main() { LL n ; int a , b , c , d ; while( cin >> n , n ) { a = b = c = d = 1 ; while( n != 1 ) { while( n % 2 == 0 ) { n /= 2 ; a++ ; } while( n % 3 == 0 ) { n /= 3 ; b++ ; } while(n % 5 == 0 ) { n /= 5 ; c++ ; } while( n % 7 == 0 ) { n /= 7 ; d++ ; } } cout << ( a * b * c * d ) << endl ; } return 0 ; }