UVA 107

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int m,n;
    while(cin>>m>>n)
    {
        if(m==0&&n==0)break;
        if(m==n&&n==1)
            cout<<"0 1"<<endl;
        else
        {
            int k=1;
            for(k=1;;k++)
            {
                if((int)(pow(1+pow(n,1.0/k),k)+0.1)>=m)
                    break;
            }
            int temp=(int)(pow(n*1.0,1.0/k)+0.1);
            int res=0;
            int res1=0;
            for(int i=0;i<k;i++)
            {
                res+=(pow(temp*1.0,i)+0.1);
                res1+=((int)(pow(temp*1.0,i)+0.1)/(pow(temp+1.0,i))*m);
            }
            res1+=n;
            cout<<(int)res<<" "<<(int)res1<<endl;
        }
    }
    return 0;
}

 

posted @ 2012-04-28 12:08  open your eyes  阅读(235)  评论(0)    收藏  举报