|
|
back to boardNeed help. Solution too slow. Code included Can someone help me? With this source it is working for 2.031. How can I improve it? #include<iostream> using namespace std; long long nod(long long a,int b){ while(a!=0&&b!=0){ if(a>b) a%=b; else b%=a; } return a+b; } int main() { long long last[50000]; int n,k,i,j,l,br=0; cin>>n>>k; last[0]=1; for(i=0;i<=n;i++) { last[i]=1; for(j=i-1;j>0;j--)last[j]=last[j]+last[j-1]; } //cout<<last[k]<<endl; for(l=2;l<last[k];l++){ if(nod(last[k],l)!=1) br++; while(last[k]%l==0)last[k]/=l;
} cout<<br<<endl; //system("pause"); return 0; } |
|
|