Question Link
Question:Enter two integers n and m to obtain the largest integer k so that m ^ K is n! .
Ideas:M ^ K is equal to the K-power sum of all the quality factors of M, so you only need to find the quality factor in m in n! The smallest power obtained in all is the value of K.
code:
# Include <iostream> # include <cstdio> # include <cstring> # include <cmath> # include <algorithm> using namespace STD; const int INF = 0x3f3f3f; int n, m; int main () {int CAS; int T = 1; scanf ("% d", & CAS); While (CAS --) {scanf ("% d ", & M, & N); printf ("case % d: \ n", t ++); int K = 2; int ans = inf; while (M! = 1) {int CNT = 0; while (M % K = 0) {M/= K; CNT ++;} If (CNT) {int A = 0; for (INT I = 0; I <= N; I + = k) {if (I % K = 0 & I! = 0) {int temp = I; while (TEMP % K = 0) {A ++; temp/= K ;}} A = A/CNT; ans = min (ANS, a);} k ++;} If (ANS) printf ("% d \ n", ANS ); else printf ("impossible to divide \ n");} return 0 ;}
Uva10780-again Prime? No time. (decomposition quality factor)