10190 TE why? please help me any body

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

Moderator: Board moderators

10190 TE why? please help me any body

Postby @mjad » Thu Jul 29, 2010 7:52 am

here is my code

Code: Select all
#include<iostream>
#include<queue>
using namespace std;


int main()
{
   unsigned long int n,b;

   while(1)
   {
      level:
      queue<int>q;

      cin>>n>>b;
      
      while(n>1)
      {
         if(n%b==0){
            q.push (n);
            n=n/b;
            
         }
         else
         if(n%b<b&&n>1){
            cout<<"Boring!"<<endl;
            goto level;
         }
      }
      q.push (1);
      while(!q.empty ())
      {
         cout<<q.front()<<" ";
         q.pop ();
      }
      cout<<endl;


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

Re: 10190 TE why? please help me any body

Postby @mjad » Mon Aug 02, 2010 4:29 am

now my code is wrong answer
any body give me some critical problem

here is my test cases:
input like:
2 2
1 1
1 0
2 0
2 5
3 6
6 3
125 5
81 3
80 2

output :

2 1
Boring!
Boring!
Boring!
Boring!
Boring!
Boring!
125 25 5 1
81 27 9 3 1
Boring!
Boring!
@mjad
New poster
 
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

Re: 10190 TE why? please help me any body

Postby helloneo » Mon Aug 02, 2010 6:52 am

There are some test cases you can try..
Here..

viewtopic.php?t=8289
helloneo
Guru
 
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10190 TE why? please help me any body

Postby @mjad » Wed Aug 04, 2010 3:42 pm

here is my new code
but i have faced still TLE why?
please help me

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 <int >q;
      if(b==0||n==0||(n==1&&b==1)||n<b)
      {
         printf("Boring!\n");
         continue;
      }
      while(n>0)
      {
         if(n%b==0||(n%b==1&&n==1)){
            q.push (n);
            n/=b;
         }
         else if(n%b<b&&n%b>=1){
            printf("Boring!");
            goto l;
         }
         
      }
      while(!q.empty ())
      {
         printf("%d ",q.front ());
         q.pop ();
      }
l:
      printf("\n");


   }
   
    return 0;
}

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

10190 why runtime error?

Postby @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

Re: 10190 TE why? please help me any body

Postby shoaib7k » Thu Aug 18, 2011 10:37 pm

i got presentation error... here is my code...[/code][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[i]=n;
n/=m;
i++;
}
else
{
printf("Boring!");
goto l;
}
}
for(j=0;j<i;j++)
printf("%d ",a[j]);
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

Postby 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]);
Imran Bin Azad
New poster
 
Posts: 3
Joined: Thu Jun 03, 2010 8:55 pm

Re: 10190 TE why? please help me any body

Postby 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?
quietroit
New poster
 
Posts: 2
Joined: Wed Nov 02, 2011 9:06 pm

Re: 10190 TE why? please help me any body

Postby shoaib7k » Tue Mar 20, 2012 12:54 pm

now i get wrong answer.....
shoaib7k
New poster
 
Posts: 10
Joined: Thu Aug 18, 2011 7:45 pm


Return to Volume CI

Who is online

Users browsing this forum: No registered users and 1 guest