|
|
back to boardWhy WA in test 2. My code here. Please help me. #include<stdio.h> #include<conio.h> long int i,j,n,m,aa,bb,cc,lap,k,l; int a[50001],sont; int dem[50001]; long int kq; void InitPrime(); long int Max(long int x,long int y); long int Min(long int x,long int y); void InitDem(); void Test(); int main() { scanf("%ld %ld",&n,&m); aa=Max(n,m); bb=Min(n,m); cc=aa-bb;
InitDem(); InitPrime(); // Test();
lap=Max(bb,cc); i=lap+1; // tinh so nguyen to o tren tu while(i<=aa) { k=0; l=i; while(l!=1) { k++; while((l%a[k])==0) { l=l/a[k]; dem[a[k]]++; } } i++; }
// tinh so nguyen to duoi mau lap=Min(bb,cc); i=2; // tinh so nguyen to o tren tu while(i<=lap) { k=0; l=i; while(l!=1) { k++; while((l%a[k])==0) { l=l/a[k]; dem[a[k]]--; } } i++; }
//dem ket qua kq=0; i=2; while(i<=aa) { if(dem[i]!=0) kq+=dem[i]; i++; } printf("%ld",kq);
getch(); return 0; } void InitDem() { i=1; while(i<=aa) { dem[i]=0; i++; } } long int Max(long int x,long int y) { if(x<=y) return y; return x; } long int Min(long int x,long int y) { if(x<=y) return x; return y; } void InitPrime() { int flag; long int x; a[1]=2; a[2]=3; a[3]=5; a[4]=7; i=4; x=11; while(x<aa+1) { j=2; flag=1; while(j*j<x) { if(x%j==0) { flag=0; break; } j++; } if(flag==1) { a[++i]=x; } x+=2; } sont=i; } void Test() { for(i=1;i<=sont;i++) printf("%d\n",a[i]); // getch(); } Re: Why WA in test 2. My code here. Please help me. Hi, Try these test cases: Test Cases 200000 40000 9011 100000 35000 6109 123456 12345 3892 987654 98765 25861 560011 12000 5255 340999 43560 11372 235000 34001 8723 89340 10000 3123 98112 23 35 4567 456 212 Varun Re: Why WA in test 2. My code here. Please help me. Hi, Try these test cases: Test Cases 200000 40000 9011 100000 35000 6109 123456 12345 3892 987654 98765 25861 560011 12000 5255 340999 43560 11372 235000 34001 8723 89340 10000 3123 98112 23 35 4567 456 212 Varun N M between 1 & 50 000 |
|
|