题意:给你一个正整数n, 找到一个最小的数m,使得n/m为质数。
题解:质因数分解
1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 typedef long long ll; 5 6 int main() 7 { 8 ll n; 9 while( ~scanf( "%I64d", &n ) ) 10 { 11 if( n == 1 ) 12 { 13 puts( "0" ); 14 continue; 15 } 16 ll ans = n, cnt; 17 for( ll i = 2; i*i <= n; ++i ) 18 if( n % i == 0 ) 19 { 20 while( n % i == 0 ) { 21 n /= i; 22 cnt = i; 23 } 24 } 25 if( n > 1 ) cnt = n; 26 printf( "%I64d\n", ans/cnt ); 27 } 28 return 0; 29 }
时间: 2024-10-13 12:25:05