Page 6 of 8

Posted: Mon Feb 12, 2007 10:42 am
by FAQ
Thanks a lot! I use GCC so I often use iostream for both printf and cout...

I'm confused when we have a sequence of length 1.

Posted: Fri Jul 20, 2007 2:21 am
by kunigas
When n = 1 and any m, shouldn't we print :

Code: Select all

1
This sequence does not violate any rule, because k = 1:
1) a[1] = 1 and 1 < i <= 1. since there's no such i, that's ok.
2) 1 <= i < 1 the same as above.
3) a[1], also ok.

But I was getting wa when assuming this...
Could someone explain me?

Posted: Fri Jul 20, 2007 6:30 pm
by Jan
Read the second rule
a is divisible by m (that is, a mod m = 0) for all 1 <= i < k

So, is your assumption right?

why WA??

Posted: Sun Dec 30, 2007 5:31 pm
by rifayat samee_du
Why WA???
please help me

Code: Select all

#include<stdio.h>
#include<string.h>
#include<math.h>
#define eps 0.0000001
int main()
{	
	int n,m,r,k,k1;
	double re;
	
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		
		
	  if(n==1||m==1)printf("Boring!\n");
	   else if(n==0||m==0)printf("Boring!\n");

	  else	
	  {	    
		  re=(double)(log(n)/log(m));
			
		  k=floor(re);
		  k1=ceil(re);
		  	
		//printf("%lf %d %d %lf",re,k,k1,re-k);
		
	   if((re-k)<eps||(k1-re)<eps)
	   {
			printf("%d",n);
			while(1)
			{
				r=n/m;
				printf(" %d",r);
				n=r;
				if(r==1)break;

			}
		printf("\n");
	   }
		else
		{
			printf("Boring!\n");
		}
	
	  }

	}


	return 0;

}	 

RE..

Posted: Thu Mar 06, 2008 7:13 am
by Obaida
Some one please help me.... Got Runtime Error.... I couldn't find it....

Posted: Sat Mar 08, 2008 11:13 am
by Jan
The given numbers are non negative. So, there can be cases like..

Input:

Code: Select all

5 0
Output:

Code: Select all

Boring!
And check your spelling.

RE/....

Posted: Sat Mar 08, 2008 11:46 am
by Obaida
My edited part is....

Posted: Sat Mar 08, 2008 11:54 am
by Jan
Check the cases...

Input:

Code: Select all

100 1
Output:

Code: Select all

Boring!
Hope it helps.

WA...

Posted: Sat Mar 08, 2008 12:00 pm
by Obaida
Now got WA....

Thank You

Posted: Sat Mar 08, 2008 12:06 pm
by Obaida
Actually I am so yong to do ACM and become exited.... That's why I get WA.... Now I got Acc.. Thank You..

Re: 10190 - Divide, But Not Quite Conquer!

Posted: Mon Apr 26, 2010 10:59 pm
by mustak

Code: Select all

Acc At last
:)

10190 TE why? please help me any body

Posted: Thu Jul 29, 2010 7:52 am
by @mjad
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;
}

Re: 10190 TE why? please help me any body

Posted: Mon Aug 02, 2010 4:29 am
by @mjad
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!

Re: 10190 TE why? please help me any body

Posted: Mon Aug 02, 2010 6:52 am
by helloneo
There are some test cases you can try..
Here..

http://acm.uva.es/board/viewtopic.php?t=8289

Re: 10190 TE why? please help me any body

Posted: Wed Aug 04, 2010 3:42 pm
by @mjad
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;
}