11185 - Ternary

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

Moderator: Board moderators

User avatar
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

11185 - Ternary

Post by linux » Mon Jul 23, 2007 8:06 am

I'm getting Output limit exceed. Can you suggest why?

Code: Select all

#include<stdio.h>

main () {
	long long n;
	short ind,res[1000],i;
	
	while (scanf("%lld",&n) && n!=-1) {
		ind =0;
                [removed after AC.
	}

	return 0;
}
:oops:
Last edited by linux on Mon Jul 23, 2007 1:48 pm, edited 1 time in total.
Solving for fun..

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Mon Jul 23, 2007 8:34 am

From problem statement.
Input is terminated by a line containing a negative value.
It might not end with -1.

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Jul 23, 2007 9:08 am

"11185 OLE!!!!!!" is not the way to open a thread in this forum. Read the sticky post.
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.

User avatar
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Post by linux » Mon Jul 23, 2007 1:47 pm

Thanks very much for your help and to inform me about that. That's a good idea!
I got AC. :P
Last edited by linux on Thu Nov 13, 2008 3:33 pm, edited 1 time in total.
Solving for fun..

User avatar
kana
New poster
Posts: 19
Joined: Mon Mar 13, 2006 6:03 pm
Location: dhaka

Post by kana » Sun Aug 26, 2007 9:09 pm

i'm getting Runtime time error with this one....can anyone help me?

Code: Select all

    deleted
Last edited by kana on Wed Sep 12, 2007 9:14 pm, edited 2 times in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Aug 28, 2007 2:07 pm

Why you are using such a big array?
Ami ekhono shopno dekhi...
HomePage

User avatar
kana
New poster
Posts: 19
Joined: Mon Mar 13, 2006 6:03 pm
Location: dhaka

Post by kana » Tue Aug 28, 2007 9:44 pm

is that the only problem in my code? with a smaller array size it shows invalid memory reference. what should i do?

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Aug 28, 2007 9:53 pm

Your algorithm is not correct. Check your code for n=41. Hope it helps.
Ami ekhono shopno dekhi...
HomePage

User avatar
oliveralderete
New poster
Posts: 3
Joined: Wed Aug 29, 2007 4:05 am
Contact:

none

Post by oliveralderete » Wed Sep 05, 2007 11:10 am

1000000000 = 2120200200021010001
try it!
:roll:

remember end of input is a NEGATIVE number.

i got AC just doing a recursive func two lines code.

sorry, my english is not very well!

User avatar
kana
New poster
Posts: 19
Joined: Mon Mar 13, 2006 6:03 pm
Location: dhaka

Post by kana » Wed Sep 12, 2007 9:17 pm

thnx jan & oliveralderete!!! i've got it acc :D

Md. Mijanur Rahman
New poster
Posts: 9
Joined: Thu Nov 13, 2008 2:08 pm

Re: 11185 - Ternary

Post by Md. Mijanur Rahman » Thu Nov 13, 2008 2:18 pm

Thank you so much, I have got accepted now.
Last edited by Md. Mijanur Rahman on Thu Nov 13, 2008 6:28 pm, edited 1 time in total.

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

Re: 11185 - Ternary

Post by helloneo » Thu Nov 13, 2008 4:33 pm

Well.. Maybe your code print an extra '\n' when n == 0 :-)


Ps. Remove your code after AC.. :-)

User avatar
vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 11185 - Ternary

Post by vahid sanei » Fri Feb 06, 2009 10:31 am

here is my Acc code

Code: Select all

 code removed by moderator!
i want know other solution for converting a numbers to other base
thanks in advance
Impossible says I`m possible

ahmed
New poster
Posts: 9
Joined: Tue Mar 17, 2009 6:36 pm

Re: 11185 - Ternary

Post by ahmed » Sun Mar 22, 2009 7:16 pm

I don't know why I am getting WA.As far as I know my logic is right.Please give me any suggestion about why I am getting WA.My code is given below:-

Code: Select all

#include<iostream>
#include<cmath>

using namespace std;

int main(void)
{
	double num,ter,b;

	while(cin >> num)
	{
		if(num<0.00)
			break;
		else
		{
			ter=0.0;
			for(b=1.0;num>2.0;num=floor(num/3.0),b*=10.0)
			{
				ter+=(fmod(num,3.0))*b;
			}
			ter+=num*b;
			printf("%.0lf\n",ter);
		}
	}
	return 0;
}


hemanth.avs
New poster
Posts: 1
Joined: Mon Jun 08, 2009 5:48 am

Re: 11185 - Ternary- plz provide me some test cases

Post by hemanth.avs » Mon Jun 08, 2009 5:54 am

I don't know why I am getting WA.As far as I know my logic is right.Please give me any suggestion about why I am getting WA.My code is given below:-

Code: Select all


#include<iostream>
using namespace std;
int main()
{
long long num;
cin >> num;
while(num>=0)
{	
long long sum = 0;
while(num!=0)
{
long long rem;
rem = num%3;
num = num/3;
sum = 10*sum + rem;
}
while(sum!=0)
{	
long long rem;
rem = sum%10;
sum = sum/10;
num = 10*num + rem;
}	
cout << num << endl;
cin >> num;
}
return 0;
}





Post Reply

Return to “Volume 111 (11100-11199)”