10922 - 2 the 9s

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

Moderator: Board moderators

<:3)~~
New poster
Posts: 16
Joined: Wed Dec 06, 2006 6:57 pm

Post by <:3)~~ » Wed Dec 13, 2006 8:42 pm

Thx again dude!
...and I Think u are really a great helper and a very great observer.
Thanks.

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

10922 - 2 the 9s

Post by apurba » Mon Dec 17, 2007 10:31 pm

i am getting wrong answer with the code, but it is giving correct output.
can anyone pls check that out?
here is my code..............

Code: Select all


deleted after acc.


thanks in advance.

if not possible give some test cases.
Last edited by apurba on Wed Dec 19, 2007 2:34 am, edited 2 times in total.

Code: Select all

keep dreaming...

User avatar
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG » Mon Dec 17, 2007 10:58 pm

I think this should help you.

Input:

Code: Select all

9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
360
564588669987
0
Output:

Code: Select all

9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 is a multiple of 9 and has 9-degree 3.
360 is a multiple of 9 and has 9-degree 1.
564588669987 is a multiple of 9 and has 9-degree 2.

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

explain?

Post by apurba » Tue Dec 18, 2007 11:25 pm

it seems to me that the degree of 9 for the first input is 4.
but in your output it is 3.
explain pls

Code: Select all

keep dreaming...

User avatar
CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...

Post by CMG » Wed Dec 19, 2007 1:49 am

9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
sum1 = 819
sum2 = 18
sum3 = 9

therefore it has degree 3.

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

10922

Post by apurba » Wed Dec 19, 2007 2:43 am

thanks.
your information was really helpful.
i have got acc.

Code: Select all

keep dreaming...

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

WA: 10922 - 2 the 9s

Post by saiful_sust » Fri Aug 29, 2008 11:24 pm

cut after AC
Last edited by saiful_sust on Mon Sep 01, 2008 11:07 pm, edited 1 time in total.

User avatar
MSH
New poster
Posts: 5
Joined: Sat Aug 23, 2008 8:25 am
Location: Iran
Contact:

Re: 10922 - 2 the 9s

Post by MSH » Sat Aug 30, 2008 7:42 pm

Try this input :
99999999999
Your program gives :
99999999999 is a multiple of 9 and has 9-degree 2.
But the answer is :
99999999999 is a multiple of 9 and has 9-degree 3.
I hope it helps you to correct your code!
Mohammad Shokri

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: WA: 10922 - 2 the 9s

Post by saiful_sust » Mon Sep 01, 2008 8:52 am

thanks 4 ur reply
BUT?????

i don't understand it..
how it is ans 3.

rajib_sust
New poster
Posts: 16
Joined: Sun Mar 02, 2008 10:34 am
Location: SUST , Sylhet, Bangladesh

Re: 10922 - 2 the 9s

Post by rajib_sust » Mon Sep 01, 2008 10:04 am

saiful_sust use code tag for input code

Code: Select all

here
rajib
sust
life is beautiful like coding

User avatar
MSH
New poster
Posts: 5
Joined: Sat Aug 23, 2008 8:25 am
Location: Iran
Contact:

Re: WA: 10922 - 2 the 9s

Post by MSH » Mon Sep 01, 2008 3:23 pm

saiful_sust wrote:thanks 4 ur reply
BUT?????

i don't understand it..
how it is ans 3.
99999999999
Sum1 = 99
Sum2 = 18
Sum3 = 9
So it has 9-degree 3.
Mohammad Shokri

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: WA: 10922 - 2 the 9s

Post by saiful_sust » Mon Sep 01, 2008 11:01 pm

cut after AC... :)
thanks MSH for ur input....

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

Re: acm problem 10922

Post by sohel » Sat Nov 29, 2008 9:56 am

Search the board first!
Don't create a new thread for a problem that already exists. There are plenty of other threads related to this problem. Make your post in an existing thread.

And why have you posted it under "ACM ICPC Archive Board". This is not the right place for this problem.

asif_khan_ak_07
New poster
Posts: 25
Joined: Fri Apr 17, 2009 8:24 am

Re: 10922 - 2 the 9s

Post by asif_khan_ak_07 » Wed Jul 29, 2009 9:12 pm

please identify the mistake in my code..........is there any critical input??

Code: Select all

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{


	//freopen("10922.txt","r",stdin);
	char in[1500],c[1];
	int ans,ns,temp,t;


	while(gets(in))
	{

		if(in[0]=='0'&&strlen(in)==1)
			exit(0);
		
		ans=0;
	
	


	ns=1;
	for(int i=0;in[i];i++)
	{
	
		c[0]=in[i];
		in[i]=atoi(c);
		ans=ans+in[i];
	
	}

		for(int j=0;in[j];j++)
			printf("%d",in[j]);
	

		
		if(ans%9!=0)
		{	
			
			printf(" is not a multiple of 9.\n");
			continue;
		
		}

	
		
		while(ans>9)
		{
			
			temp=ans;
			ans=0;
			
			while(temp>0)
			{
			
				t=temp%10;
				ans=ans+t;
				temp=temp/10;
			
			}


			ns++;
		
		}

	
	printf(" is a multiple of 9 and has 9-degree %d.\n",ns);
	
	
	
	
	
	}
return 0;
}

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re: 10922 - 2 the 9s

Post by DD » Mon Mar 14, 2011 1:52 am

The only special case may be 9, whose 9-degree is 1. For other cases, just simulate it and count the degree. :D
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.

Post Reply

Return to “Volume 109 (10900-10999)”