## 10922 - 2 the 9s

Moderator: Board moderators

<:3)~~
New poster
Posts: 16
Joined: Wed Dec 06, 2006 6:57 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

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.

``````

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...``

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

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?

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...``

CMG
New poster
Posts: 37
Joined: Sat Dec 08, 2007 5:01 am
Location: ...
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

thanks.
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

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

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

### Re: 10922 - 2 the 9s

Try this input :
99999999999
99999999999 is a multiple of 9 and has 9-degree 2.
99999999999 is a multiple of 9 and has 9-degree 3.
I hope it helps you to correct your code!

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

### Re: WA: 10922 - 2 the 9s

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

### Re: 10922 - 2 the 9s

saiful_sust use code tag for input code

Code: Select all

``````here
``````
rajib
sust
life is beautiful like coding

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

### Re: WA: 10922 - 2 the 9s

BUT?????

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

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

### Re: WA: 10922 - 2 the 9s

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

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

### Re: acm problem 10922

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

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

The only special case may be 9, whose 9-degree is 1. For other cases, just simulate it and count the degree.
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.