Page 2 of 3
Posted: Wed Dec 13, 2006 8:42 pm
by <:3)~~
Thx again dude!
...and I Think u are really a great helper and a very great observer.
Thanks.
10922 - 2 the 9s
Posted: Mon Dec 17, 2007 10:31 pm
by apurba
i am getting wrong answer with the code, but it is giving correct output.
can anyone pls check that out?
here is my code..............
thanks in advance.
if not possible give some test cases.
Posted: Mon Dec 17, 2007 10:58 pm
by CMG
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.
explain?
Posted: Tue Dec 18, 2007 11:25 pm
by apurba
it seems to me that the degree of 9 for the first input is 4.
but in your output it is 3.
explain pls
Posted: Wed Dec 19, 2007 1:49 am
by CMG
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
sum1 = 819
sum2 = 18
sum3 = 9
therefore it has degree 3.
10922
Posted: Wed Dec 19, 2007 2:43 am
by apurba
thanks.
your information was really helpful.
i have got acc.
WA: 10922 - 2 the 9s
Posted: Fri Aug 29, 2008 11:24 pm
by saiful_sust
cut after AC
Re: 10922 - 2 the 9s
Posted: Sat Aug 30, 2008 7:42 pm
by MSH
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!
Re: WA: 10922 - 2 the 9s
Posted: Mon Sep 01, 2008 8:52 am
by saiful_sust
thanks 4 ur reply
BUT?????
i don't understand it..
how it is ans 3.
Re: 10922 - 2 the 9s
Posted: Mon Sep 01, 2008 10:04 am
by rajib_sust
saiful_sust use code tag for input code
rajib
sust
Re: WA: 10922 - 2 the 9s
Posted: Mon Sep 01, 2008 3:23 pm
by MSH
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.
Re: WA: 10922 - 2 the 9s
Posted: Mon Sep 01, 2008 11:01 pm
by saiful_sust
cut after AC...
thanks MSH for ur input....
Re: acm problem 10922
Posted: Sat Nov 29, 2008 9:56 am
by sohel
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.
Re: 10922 - 2 the 9s
Posted: Wed Jul 29, 2009 9:12 pm
by asif_khan_ak_07
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;
}
Re: 10922 - 2 the 9s
Posted: Mon Mar 14, 2011 1:52 am
by DD
The only special case may be 9, whose 9-degree is 1. For other cases, just simulate it and count the degree.
