Page 12 of 14
Posted: Wed Feb 13, 2008 4:15 pm
by Raffan_033
I'm continuously getting WA. Anybody PLZ HELP..
#include<stdio.h>
#include<math.h>
int main(void)
{
int frequency[25],i,N,tempN;
int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
scanf("%d",&N);
while((N>=1)&&(N<=100))
{
printf("\n%3d! =",N);
if(N==1)
{
printf("%3d",0);
goto label;
}
for(i=0;i<25;i++)
{
if(prime[i]>N)
break;
frequency[i]=0;
tempN=N;
while(tempN>=prime[i])
{
frequency[i]+=(tempN/prime[i]);
tempN/=prime[i];
}
printf("%3d",frequency[i]);
if(i==14)
printf("\n ");
}
label:
scanf("%d",&N);
}
return 0;
}
160 WA
Posted: Sat Mar 01, 2008 6:07 am
by epilos@CodeHolic
DELETE After AC
I think all output is right....
But WA....
Why???
Help me...
Posted: Sat Mar 01, 2008 8:26 am
by CSEDU_1323
sample input
53
0
Sample output
53! = 49 23 12 8 4 4 3 2 2 1 1 1 1 1 1
******1
Ur output
53! = 49 23 12 8 4 4 3 2 2 1 1 1 1 1 1
**1
use 6 space instead of 1 in d second line and increase array size to 102 for safety & print "\n" just after printing output.
HOPE THIS HELPS

Posted: Sat Mar 01, 2008 8:56 am
by epilos@CodeHolic
CSEDU_1323 wrote:sample input
53
0
Sample output
53! = 49 23 12 8 4 4 3 2 2 1 1 1 1 1 1
******1
Ur output
53! = 49 23 12 8 4 4 3 2 2 1 1 1 1 1 1
**1
use 6 space instead of 1 in d second line and increase array size to 102 for safety & print "\n" just after printing output.
HOPE THIS HELPS

Thanks.....
but i can't understand...
increase array size ===>> accepted....
program can't use arr[100]...
Why???
Sorry my poor English...
WA please help
Posted: Tue Jul 29, 2008 3:54 pm
by theharshest
please suggest a test case for which this code gives WA or please tell any other mistake..
Code: Select all
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int n;
int pr[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int f[25],j,k;
cin>>n;
while(n!=0)
{
if(n==1)
cout<<" 1! = 0"<<endl;
else
{
for(int i=0;i<25;i++)
f[i]=0;
for(int i=n;i>=1;i--)
{
k=i;
j=0;
while(k>1)
{
if(k%pr[j]==0)
{
f[j]++;
k=k/pr[j];
}
else
j++;
}
}
int t=0;
for(int k=24;k>=0;k--)
{
if(f[k]>0)
break;
else
f[k]=-1;
}
cout.setf(ios::right);
cout<<setw(3)<<n<<"! =";
while(f[t]!=-1 && t<25)
{
cout<<setw(3)<<f[t];
t++;
if(t%15==0)
cout<<endl<<" ";
}
cout<<endl;
}
cin>>n;
}
}
Re: 160 WA?? PLZ
Posted: Tue Jul 29, 2008 5:04 pm
by helloneo
Help..
Posted: Mon Aug 11, 2008 8:37 pm
by Mohiuddin
This is very annoying that i m getting wa over & over again...plzz tell me anyone where is my problem?
#include <stdio.h>
void free(int *index)
{
int i;
for(i=0;i<25;i++)
{
index
=0;
}
}
void check(int num)
{
if(num>99)
printf("%d",num);
else if(num>9)
printf(" %d",num);
else
printf(" %d",num);
}
int main()
{
int num,i,j,index[30],temp;
int primee[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
while(1)
{
scanf("%d",&num);
free(index);
if(num==0)
{
break;
}
if(num==1)
{
check(num);
printf("! = 1\n");
continue;
}
for(i=2;i<=num;i++)
{
temp=i;
for(j=0;j<25 && temp;)
{
if(temp%primee[j]==0)
{
temp/=primee[j];
index[j]++;
continue;
}
j++;
}
}
check(num);
printf("! =");
for(i=0;i<25&&index;i++)
{
check(index);
if(i==14)
printf("\n ");
}
printf("\n");
}
return 0;
}
Re: 160 WA?? format
Posted: Mon Sep 01, 2008 11:00 pm
by debugger
Hi, i cant understand the output format. Anybody will help me make the format right? Following is my code.
Code: Select all
#include<stdio.h>
int main(){
int numeretor,count=0,i,denomeretor,p[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97},fact[102]={0},j=0;
int n,k,m;
for(;;){
scanf("%d",&n);
if(n==0)
break;
numeretor=n;
for(i=0;i<25;i++){
if(p[i]>n)
{k=i; break;}
denomeretor=p[i];
count=0;
numeretor=n;
for(;;){
numeretor=numeretor/denomeretor;
count=count+numeretor;
if(numeretor<=1)
{break;}
}
fact[p[i]]=count;
}
printf("%d! =",n);
for(i=0;i<k;i++){
printf("%d ",fact[p[i]]);
if((i%15)==0)
printf("\n ");
}
printf("\n");
}
return 0;
}
please help
Re: Can't find error in Problem 160
Posted: Thu Apr 02, 2009 5:06 pm
by ahmed
plzzzzz help to find my error!!!!!
Thanks mf for your kind consideration

Re: Can't find error in Problem 160
Posted: Thu Apr 02, 2009 5:42 pm
by ahmed
I am srry.I didn't understand.I just posted in all the thread that I found.I promise it won't happen again and I have deleted all of my posts.
Re: Can't find error in Problem 160
Posted: Thu Apr 02, 2009 5:50 pm
by mf
Ok, good :)
I think the error is on line 15:
This \n in it is causing your program to print an unnecessary blank line at the very beginning of the output. Your program shouldn't do that.
For the input N=47, it also prints an unnecessary a blank line in the output, fix that too.
Re: Can't find error in Problem 160
Posted: Sun Jul 19, 2009 5:00 pm
by kymarscheng
Hello~ I get presentation error and don't know how to correct it..............Can anyone give me some advice on how to fix it?
Thx very much!!!
Code: Select all
#include <stdio.h>
int main()
{
int f,i,j,n,x;
int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
53,59,61,67,71,73,79,83,89,97};
int count[25];
while(scanf("%d",&f)==1)
{
if (f==0) break;
for (i=0; i<25; i++) count[i]=0;
for (i=2; i<=f; i++)
{
n=i;
for (j=0; j<25; j++)
{
while(n%prime[j]==0)
{
n=n/prime[j];
count[j]++;
}
}
}
printf("%3d! = ",f);
i=24;
while(count[i]==0)
{
x=i;
i--;
}
for (j=0;j<=i;j++)
{
if(j==15)
{
printf("\n ");
}
printf("%3d",count[j]);
}
printf("\n");
}
return 0;
}
Re: Can't find error in Problem 160
Posted: Wed Jul 22, 2009 2:54 pm
by mf
"Presentation Error" here at UVa judge (but not at most other places) means that your answer is basically correct, but you have too few or too many blanks/newlines somewhere.
Read the output format section again, make sure that your program's output is exactly like sample output.
Re: 160 WA.................
Posted: Fri Aug 07, 2009 1:03 pm
by nil_r
#include<stdio.h>
int main() /***** WA *****/
{
int i,j,c,n,k,l;
int a[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int b[25];
while(scanf("%d",&n)!=EOF)
{
if(n==0)
{
break;
}
for(i=0;i<25;i++)
{
b=0;
}
l=n;
k=n;
c=0;
while(k>=2)
{
n=k;
for(i=0;i<25;i++)
{
if(n%a==0)
{
while(n>1)
{
if(n%a!=0)
{
break;
}
b++;
n=n/a;
}
}
if(n==1)
{
break;
}
}
if(i>c)
{
c=i;
}
k--;
}
printf("%3d! =",l);
for(j=0;j<=c;j++)
{
printf("%3d",b[j]);
if(j==14)
{
printf("\n ");
}
}printf("\n");
}
return 0;
}
Re: 160 - Factors and Factorials
Posted: Mon Feb 22, 2010 6:49 pm
by khairul
Use 15 instead of 14 and give six blank space like as printf("\n ");
if(j==14)
{
printf("\n ");
}
try like this code:
if(j==15)
{
printf("\n ");
}
Finally check(give as input 1-100 at a time) and let me know...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 0