Again Prime? No Time.
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31675#problem/D
涨姿势了。。。
// File Name: uva10780.cpp// Author: bo_jwolf// Created Time: 2013年09月16日 星期一 21:54:27#include<vector>#include<list>#include<map>#include<set>#include<deque>#include<stack>#include<bitset>#include<algorithm>#include<functional>#include<numeric>#include<utility>#include<sstream>#include<iostream>#include<iomanip>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<ctime>using namespace std;int getsum( int n , int i ) {int ans = 0 ; while( n ){ans += n / i ; n /= i ;}return ans ;}int main(){int Case , ans , a , i , temp , m , n ;scanf( "%d" , &Case ) ;for( int j = 1 ; j <= Case ; ++j ){scanf( "%d%d" , &m , &n ) ;ans = 100000 , i = 2 ;while( m > 1 ){a = 0 ;while( m % i == 0 ){a++ ; m /= i ; }if( a ){temp = getsum( n , i ) / a ; ans = temp > ans ? ans : temp ;}i++ ;}printf( "Case %d:\n" , j ) ;if( ans ){printf( "%d\n" , ans ) ;}else{printf( "Impossible to divide\n" ) ;}}return 0;}