×

# getting wrong answer in NUMFACT

 0 #include //#include #include int pi=-1,prime[50],count[50]; int primenum(long long a) { int i,f=1; for(i=2;i<=a/2;i++) { if(a%i==0) {f=0; break; } } return f; } void push(long long a) { int i,f=0; for(i=0;i<=pi;i++) { if(prime[i]==a) {count[i]++; f=1; break; } } if(f==0) {prime[++pi]=a; count[pi]=1; } } int main() { long long a,po,k; int n,t,i,j,f,fl,l,m; scanf("%d",&t); for(i=1;i<=t;i++) { po=1; for(m=0;m<50;m++) {prime[m]=0; count[m]=0; } pi=-1; scanf("%d",&n); for(j=1;j<=n;j++) { k=2; scanf("%lld",&a); f=primenum(a); if(f==1) push(a); else { for(k=2;k<=sqrt(a)+1;k++) { while(a%k==0) { fl=primenum(k); if(fl==1) {push(k); a=a/k; } else k++; } } } } for(l=0;l<=pi;l++) po=po*(count[l]+1); printf("%lld",po); } // getch(); return 0; }  asked 16 Oct '14, 00:20 1★sarique -1●1●1●9 accept rate: 0% 2.9k●31●53

 3 Brother, let me try to help you... Try this test case 1 2 1009 9973  Remember : you have to factorize those Ais, each of them is up to 1.000.000 (10^6), there are 168 primes only less than 1000, so you are not dealing with such a big numbers... answered 16 Oct '14, 23:11 2.9k●31●53 accept rate: 9%
 0 Please indent the code properly.anyways if u think ur logic is right,then try putting '\n' after %lld in third last line,i.e it should be written as printf("%lld\n",po); instead of printf("%lld",po).Try this first and let me know. answered 16 Oct '14, 06:31 3★sandeep9 478●2●8●27 accept rate: 4% not working it is not still working after using printf("%lld\n",po); instead of printf("%lld",po) (16 Oct '14, 21:59) sarique1★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×856

question asked: 16 Oct '14, 00:20

question was seen: 488 times

last updated: 19 Oct '14, 07:22