10922 - 2 the 9s
Moderator: Board moderators
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..............
thanks in advance.
if not possible give some test cases.
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...
I think this should help you.
Input:
Output:
Input:
Code: Select all
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
360
564588669987
0
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?
it seems to me that the degree of 9 for the first input is 4.
but in your output it is 3.
explain pls
but in your output it is 3.
explain pls
Code: Select all
keep dreaming...
-
- 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.
Re: 10922 - 2 the 9s
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!
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
-
- Learning poster
- Posts: 97
- Joined: Fri Aug 22, 2008 10:18 pm
- Location: CSE.SUST.SYLHET
Re: WA: 10922 - 2 the 9s
thanks 4 ur reply
BUT?????
i don't understand it..
how it is ans 3.
BUT?????
i don't understand it..
how it is ans 3.
-
- New poster
- Posts: 16
- Joined: Sun Mar 02, 2008 10:34 am
- Location: SUST , Sylhet, Bangladesh
Re: 10922 - 2 the 9s
saiful_sust use code tag for input code
rajib
sust
Code: Select all
here
sust
life is beautiful like coding
Re: WA: 10922 - 2 the 9s
99999999999saiful_sust wrote:thanks 4 ur reply
BUT?????
i don't understand it..
how it is ans 3.
Sum1 = 99
Sum2 = 18
Sum3 = 9
So it has 9-degree 3.
Mohammad Shokri
-
- 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....
![:)](./images/smilies/icon_smile.gif)
thanks MSH for ur input....
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.
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.
-
- 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;
}
-
- 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. ![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
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?