ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1355. Bald Spot Revisited

PLEASE HELP<Always TLE#3> here is my code
Posted by Anastas 24 Feb 2008 18:34
#include<iostream>

using namespace std;

int CountOf(int n){
    int count=0,div=2;
    while(n!=1){
        while(n%div) div++;
        count++;
        n/=div;
    }
    return count+1;
}
void main()
{
    short T;
    cin>>T;
    int i,*A,*B;
    A=new int[T];
    B=new int[T];
    for(i=0;i<T;i++){
        cin>>A[i]>>B[i];
    }
    for(i=0;i<T;i++)
    {
        if(A[i]==0) cout<<0<<endl;
        else cout<<((A[i]>B[i] || B[i]%A[i]) ? 0:CountOf(B[i]/A[i]))<<endl;
    }
}