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

FAQ
Learning poster
Posts: 84
Joined: Wed Jan 28, 2004 6:23 pm

Post by FAQ »

Thanks a lot! I use GCC so I often use iostream for both printf and cout...
kunigas
New poster
Posts: 4
Joined: Mon Feb 26, 2007 4:29 am

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

Post 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?
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post 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?
Ami ekhono shopno dekhi...
HomePage
rifayat samee_du
New poster
Posts: 9
Joined: Tue Jul 11, 2006 8:44 am
Location: Beside you........

why WA??

Post 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;

}	 
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

RE..

Post by Obaida »

Some one please help me.... Got Runtime Error.... I couldn't find it....
Last edited by Obaida on Sat Mar 08, 2008 12:30 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post 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.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

RE/....

Post by Obaida »

My edited part is....
Last edited by Obaida on Sat Mar 08, 2008 12:35 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Check the cases...

Input:

Code: Select all

100 1
Output:

Code: Select all

Boring!
Hope it helps.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

WA...

Post by Obaida »

Now got WA....
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Thank You

Post 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..
try_try_try_try_&&&_try@try.com
This may be the address of success.
mustak
New poster
Posts: 8
Joined: Sun Sep 06, 2009 5:11 pm
Contact:

Re: 10190 - Divide, But Not Quite Conquer!

Post by mustak »

Code: Select all

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

10190 TE why? please help me any body

Post 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;
}
@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

Re: 10190 TE why? please help me any body

Post 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!
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10190 TE why? please help me any body

Post by helloneo »

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

http://acm.uva.es/board/viewtopic.php?t=8289
@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

Re: 10190 TE why? please help me any body

Post 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;
}

Post Reply

Return to “Volume 101 (10100-10199)”