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

WA test#2
Posted by Rustambek_UWED 12 Apr 2008 01:39
where is the problem.

please help me.
I am bored of compiling.


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b,tub,i,j,s,n,tc,m;

    cin>>n;
    for(i=0;i<n;i++)
    {
        s=0;
        tub=2;
        cin>>a>>b;
        if(a==b)
        {
            cout<<1<<endl;
            continue;
        }
        if(b%a)
        {
            cout<<0<<endl;
            continue;
        }
        if(a==1&&(b%2==0))
        {
            a=2;
            s++;
            if(b==2)
            {
                cout<<1<<endl;
                continue;
            }
        }
        if(a==1 && b%2)
        {
            a=3;
            s++;
            if(b==3)
            {
                cout<<1<<endl;
                continue;
            }
        }
        b/=a;
        tc=0;

        while(b!=1)
        {
            if(tub==3)
                tc=1;
            while(b%tub==0)
                if(b%tub==0)
                {
                    b/=tub;
                    s++;
                }
            if(tub==2)
                tub=3;
            if(b!=1&&tc==1)
            {
                for(j=tub+2;j<=b;j+=2)
                {
                    for(m=2;m<=int(sqrt(double(j)));m++)
                    {
                        if(j%2==0)
                            break;
                        if(m==int(sqrt(double(j))))
                            tub=j;
                    }
                    if(tub==j)
                        break;
                }
            }
        }
        cout<<s+1<<endl;

    }


    return 0;
}