Page 2 of 2

Posted: Mon Oct 30, 2006 8:40 pm
by Jan
Dont open a new thread if there is one already. Check the i/o set

Input:

Code: Select all

273
0
Output:

Code: Select all

273! --
   (0)  133    (1)   54    (2)   43    (3)   53    (4)   62
   (5)   38    (6)   43    (7)   40    (8)   42    (9)   41

Posted: Mon Nov 20, 2006 7:27 pm
by albet_januar
thx 4 ur reply..
i got acc.. with my silly mistake..

Posted: Sun Feb 25, 2007 12:45 pm
by algoJo
it's works in my computer but the judges said CE :(
can anybody give me some hints??

Code: Select all

Cut, Thanks to arif_pasha 
}

Posted: Mon Feb 26, 2007 1:21 am
by arif_pasha
--> AlgoJo
1. Your program should terminate on input 0

try

Code: Select all

   while(scanf("%d",&n)==1)
   {
	    if(n==0)break;

		memset(res,'0',sizeof(res));
		strcpy(t1,"2");
                ...........
2. It produces incorrect result for input 1

3. It gets "compile error" for the function "itoa". itoa function is not ansi standard.. you should use sprintf..

Code: Select all

itoa(i,t2,10);
sprintf(t2,"%d",i);
both lines does the same..

Posted: Mon Feb 26, 2007 1:13 pm
by algoJo
WooW u're right, Thanks a lot arif_pasha... :D

WA of 324

Posted: Fri Mar 02, 2007 6:04 pm
by Md.Arafat Hossain
I do not able to understand why my program produces wrong answer.
Her is my code:
#include<stdio.h>
#include<iostream.h>
int main(){
int i,j,k,b[10],n,c=0,l,m,s;
int a[800] ;

while(cin>>n){
for(i=0;i<800;i++)
a=-1;
for(i=0;i<10;i++)
b=0;

if(n<=366){
i=799;
j=n*(n-1);
while(j>9){
k=j%10;
a=k;
j=j/10;
i--;}
a=j;
for(l=n-2;l>=2;l--){
for(j=799;j>=i;j--){
k=c+l*a[j];
s=j;
m=k%10;
a[s]=m;
k=k/10;
c=k;}
while(c>9){
m=c%10;
s--;
a[s]=m;
c=c/10;}
if(c>0){
s--;
a[s]=c;}

if(i>s) i=s;
c=0;}
k=0;
for(l=0;l<10;l++){
for(j=i;j<800;j++)
if(a[j]==l)
b[l]=++k;
k=0;}
printf("%ld! ---\n",n);
for(l=0;l<10;l++){
if((l==0)&&(l==5))
printf("(%ld)%5ld",l,b[l]);
else
printf(" (%ld)%5ld",l,b[l]);
if(l==4)
printf("\n");}

printf("\n");
}}
return 0;}
[/quote][/url][/list][/list][/code]

Posted: Fri Mar 02, 2007 6:27 pm
by Piotr Gawron
your program gives wrong answer for example input (too many dashes and you shouldn't proceed test where n=0)

Re: WA of 324

Posted: Thu Aug 25, 2011 5:33 pm
by jaasilva
Can anyone help me? (I'm using Java) I can't understand why my program is getting WA. I tested it with all the input that I could find and it was right. I think that's something with the output format. Can someone verify that?

Code: Select all

import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(new BufferedInputStream(System.in));

		int num = in.nextInt();

		while (num != 0)
		{
			BigInteger res = new BigInteger("1");

			for (int i = 2; i <= num; i++)
			{
				BigInteger mul = new BigInteger("" + i);
				res = res.multiply(mul);
			}

			String result = res.toString();
			int[] freq = new int[10];

			for (int j = 0; j < result.length(); j++)
				freq[Integer.parseInt("" + result.charAt(j))]++;

			System.out.printf("%d! --\n", num);
			System.out.printf(
					"   (0) %5d\t(1) %5d\t(2) %5d\t(3) %5d\t(4) %5d\n",
					freq[0], freq[1], freq[2], freq[3], freq[4]);
			System.out.printf(
					"   (5) %5d\t(6) %5d\t(7) %5d\t(8) %5d\t(9) %5d\n",
					freq[5], freq[6], freq[7], freq[8], freq[9]);

			num = in.nextInt();
		}
	}
}

Re: WA of 324

Posted: Tue Apr 08, 2014 7:52 am
by uDebug
jaasilva wrote:Can anyone help me? (I'm using Java) I can't understand why my program is getting WA. I tested it with all the input that I could find and it was right. I think that's something with the output format. Can someone verify that?
This is the output that my AC code uses

Code: Select all

System.out.printf("   (0)%5d    (1)%5d    (2)%5d    (3)%5d    (4)%5d\n", frequencyMap['0'], frequencyMap['1'], frequencyMap['2'], frequencyMap['3'], frequencyMap['4']);   
System.out.printf("   (5)%5d    (6)%5d    (7)%5d    (8)%5d    (9)%5d\n", frequencyMap['5'], frequencyMap['6'], frequencyMap['7'], frequencyMap['8'], frequencyMap['9']);