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

@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

10190 why runtime error?

Post by @mjad » Sun Aug 15, 2010 6:57 am

anybody please help me

Code: Select all

#include<stdio.h>

int main()
{
    long int n,b;
	long int a[200000],i,j;

	//freopen("10190.txt","r",stdin);
	while(scanf("%ld %ld",&n,&b)==2)
	{
		 
		i=0;
		if(b==0||n==0||(n==1&&b==1)||n<b)
		{
			printf("Boring!");
			goto l;
		}
		while(n>0)
		{
			if(n%b==0||(n==1)){
				 
				a[i]=n;
				n/=b;
				i++;
			}
			else 
			{
				printf("Boring!");
				goto l;
			}
			 
		}
		for(j=0;j<i;j++)
			printf("%ld ",a[j]);
	 
l:
		printf("\n");


	}
   
    return 0;
}


@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

10190why runtime error? please help me!

Post by @mjad » Sun Aug 15, 2010 7:09 am

:D
i go AC
thanx a lot for your reply
Last edited by @mjad on Mon Oct 11, 2010 3:44 am, edited 1 time in total.

@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

10190why presentation error?

Post by @mjad » Sun Aug 15, 2010 7:58 am

please anybody help me
why presentation error?
i think this is write ,
but i don't get AC

my code is here
please any body help me
here is my code

Code: Select all

#include<stdio.h>
#include<queue>
using namespace std;
int main()
{
    long int n,b;

	while(scanf("%ld %ld",&n,&b)==2)
	{
		 queue<long int>q;

		if(n<=1||b<=1)
		{
			printf("Boring!");
			goto l;
		}
		while(n>0)
		{
			if(n%b==0||(n==1)){
				 
				q.push(n);
				n/=b;
				
			}
			else 
			{
				printf("Boring!");
				goto l;
			}
			 
		}
		while(!q.empty())
		{
			printf("%ld ",q.front());
			q.pop();
		}
	 
l:
		printf("\n");


	}
   
    return 0;
}


helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10190why presentation error?

Post by helloneo » Sat Oct 09, 2010 8:15 pm

@mjad wrote:please anybody help me
why presentation error?
i think this is write ,
but i don't get AC

my code is here
please any body help me
here is my code
You're printing an extra space after the last number..

shoaib7k
New poster
Posts: 10
Joined: Thu Aug 18, 2011 7:45 pm

Re: 10190 TE why? please help me any body

Post by shoaib7k » Thu Aug 18, 2011 10:37 pm

i got presentation error... here is my code...[/code] #include<stdio.h>
int main()
{
int n,m,k,i,j,a[200000];
while(scanf("%d%d",&n,&m)!=EOF)
{
i=0;
if(m<2 || n<m)
{
printf("Boring!");
goto l;
}
while(n>0)
{
if(n%m==0 || n==1)
{
a=n;
n/=m;
i++;
}
else
{
printf("Boring!");
goto l;
}
}
for(j=0;j<i;j++)
printf("%d ",a[j]);
l:
printf("\n");
}
return 0;
}

Imran Bin Azad
New poster
Posts: 3
Joined: Thu Jun 03, 2010 8:55 pm

Re: 10190 TE why? please help me any body

Post by Imran Bin Azad » Tue Oct 11, 2011 8:23 pm

you are printing an extra white space after the last integer

Code: Select all

for(j=0;j<i;j++)
printf("%d ",a[j]);

quietroit
New poster
Posts: 2
Joined: Wed Nov 02, 2011 9:06 pm

Re: 10190 TE why? please help me any body

Post by quietroit » Wed Nov 02, 2011 9:19 pm

you are printing an extra white space after the last integer
Is this what causing a problem?

Atish
New poster
Posts: 2
Joined: Fri Jun 10, 2011 5:54 am

Re: 10190 - Divide, But Not Quite Conquer!

Post by Atish » Thu Nov 03, 2011 9:41 pm

if(n>=n&&n!=0&&m!=0&&m!=1&&n!=1) just use this condition and check your printf

Atish
New poster
Posts: 2
Joined: Fri Jun 10, 2011 5:54 am

Re: 10190

Post by Atish » Thu Nov 03, 2011 9:44 pm

new comer wrote:Whenever I submitt 10190, it says "output limit exceeded". I don't understand where is the problem. My code is like this:

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

void main()
{
long m,n,result;

for(;(scanf("%ld %ld",&m,&n))==2;)
{
if((ceil(logl(m)/logl(n))) == (floor(logl(m)/logl(n)))) // you should use a condition here and check printf
{
printf("%ld ",m);
for(;;)
{
m=m/n;
printf("%ld ",m);
if(m==1)
break;
}
}
else
{
printf("Boring!");
}
printf("\n");
}
}

HELP ME![/c]

shoaib7k
New poster
Posts: 10
Joined: Thu Aug 18, 2011 7:45 pm

Re: 10190 - Divide, But Not Quite Conquer!

Post by shoaib7k » Tue Mar 20, 2012 10:55 am

what is wrong with my code???

Code: Select all

#include<stdio.h>
int main()
{
    int n,m,k,i,h,a[100];
    while(scanf("%d%d",&n,&m)==2)
    {
      if(m<2 || n<2 || n<m)
      printf("Boring!");
      else
      {
      k=1;
      a[0]=n;
      for(i=1;i<=100;i++)
      {
        a[i]=n/m;
        n=a[i];
        if(n==0)
        break;
        k++;
      }
      for(i=0;i<k-1;i++)
      {
        if(a[i]%m!=0)
        {
          printf("Boring!");
          goto l;
          h=a[i];
          break;
        }
      }
      for(i=0;i<k;i++)
      printf("%d ",a[i]);
      }
 l:     printf("\n");
    }
    return 0;
}

shoaib7k
New poster
Posts: 10
Joined: Thu Aug 18, 2011 7:45 pm

Re: 10190 TE why? please help me any body

Post by shoaib7k » Tue Mar 20, 2012 12:54 pm

now i get wrong answer.....

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10190 - Divide, But Not Quite Conquer!

Post by brianfry713 » Tue Mar 20, 2012 9:32 pm

you are printing an extra white space after the last integer
Check input and AC output for thousands of problems on uDebug!

shoaib7k
New poster
Posts: 10
Joined: Thu Aug 18, 2011 7:45 pm

Re: 10190 - Divide, But Not Quite Conquer!

Post by shoaib7k » Tue Mar 20, 2012 10:12 pm

still wrong ans....

sajal2k8
New poster
Posts: 16
Joined: Mon Nov 18, 2013 5:15 pm

10190 Why RE??

Post by sajal2k8 » Sat Dec 14, 2013 12:49 am

Code: Select all

#include <iostream>

using namespace std;

int main()
{
    unsigned long long int n,j,m,i=1,num[10000],a,c=0;
    while(cin>>n>>m)
    {
        num[0]=n;
        if(n==1)
        c=1;
        while(n>1 && m!=1)
        {
            a=n/m;
            if(n%m==0)
            num[i]=a;
            else
            {
                c=1;
                break;
            }
            n=n/m;
            i++;
        }
        if(m==1 || n==0)
        c=1;
        if(c==1)
        cout<<"Boring!\n";
        else
        {
            for(j=0;j<i;j++)
            {
                cout<<num[j];
                if(j!=i-1)
                cout<<" ";
            }
            cout<<"\n";
        }
        i=1;c=0;
    }
    return 0;
}
Thanks in advance..

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10190 Why RE??

Post by brianfry713 » Tue Dec 17, 2013 11:00 pm

What if m = 0?
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 101 (10100-10199)”

Who is online

Users browsing this forum: No registered users and 1 guest