10190 - Divide, But Not Quite Conquer!

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 10190 - Divide, But Not Quite Conquer!

Post by Shahidul.CSE »

I am getting WA. I have tested all the cases shared on this forum, all are ok. Can anyone give some more input-output for this problem?

Whats wrong in my code? Here is my code:

Code: Select all

#include <iostream>
#include <math.h>
#include <stdio.h>

int main()
{
    int n, m, i=1, d, p1, pwr;
    double p, pw;
    while(scanf("%d %d", &n, &m)!=EOF)
    {
        if(m<2 || n<2 || n<m)
        {
            printf("Boring!\n");
            continue;
        }
        p=log(n)/log(m);
        p1=(int)p;
        pw=pow(m, p1);
        pwr=(int)pw;
        if(pwr!=n)
            printf("Boring!\n");
        else
        {
            d=n;
            while(d>1)
            {
                printf("%d ", d);
                d/=m;
            }
            printf("%d\n",d);
        }
    }
    return 0;
}
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Post Reply

Return to “Volume 101 (10100-10199)”