ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1091. Tmutarakan Exams

where 'm wrong? why i get WA?
Posted by Silviu Ganceanu 19 Feb 2003 02:24

#include <iostream.h>

void Read();

int
main(){
 Read();
 return (0);
}

long Mat[40][40];

void
Constr(){
 int i, j;
 for(i=0;i<=25;i++)
  Mat[i][0]=1;

 for(i=1;i<=25;i++)
  for(j=1;j<=i;j++)
   Mat[i][j]=Mat[i-1][j-1]+Mat[i-1][j];
}


void
Read(){
 int K, N;
  cin>>K>>N;
 Constr();
 int i, j;
 long Count=0;

 for(i=2;i<=N;i++)
  if(N/i>=K){
   long Cat=Mat[N/i][K];

    for(j=2;j<i;j++){
     if(i%j==0){Cat=0; break;}
     if(N/(j*i)>=K)Cat-=Mat[N/(j*i)][K];
    }
    if(Cat>0)Count+=Cat;
    if(Count>=10000){cout<<10000<<'\n';return;}
  }
  else break;
  cout<<Count<<'\n';
}