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 1055. Combinations

<TOP SECRET> 15 лет колоний и лагерей будет
Posted by And IV 29 Jun 2007 21:05
#include <iostream>
using namespace std;
int i,o,n,m,k,nm[50001],n_m[50001],n_n[50001],c;
bool bb[50001];
int main()
{
cin>>n>>m;
bb[1]=true;
for(i=2;i<=n;i++)
  if (!bb[i])
  for(o=2*i;o<=n;o+=i)bb[o]=true;
for(i=2;i<=n;i++)
  if (bb[i])
  {
  k=i;
  for(o=2;o<=i;o++)
  if (!bb[o])
    {
    while(k%o==0)
     {
     nm[o]++;
     k/=o;
     }
    if (k==1) break;
    }
  }
  else
  {
  nm[i]++;
  }
for(i=2;i<=m;i++)
  if (bb[i])
  {
  k=i;
  for(o=2;o<=i;o++)
  if (!bb[o])
    {
    while(k%o==0)
     {
     n_m[o]++;
     k/=o;
     }
     if (k==1) break;
    }
  }
  else
  {
  n_m[i]++;
  }
for(i=2;i<=n-m;i++)
  if (bb[i])
  {
  k=i;
  for(o=2;o<=i;o++)
  if (!bb[o])
    {
    while(k%o==0)
     {
     n_n[o]++;
     k/=o;
     }
    if (k==1) break;
    }
  }
  else
  {
  n_n[i]++;
  }
for(i=2;i<=n;i++)
  {
  nm[i]-=n_n[i]+n_m[i];
  if (nm[i]>0) c++;
  }
cout<<c;
return 0;
}
Re: <TOP SECRET> 15 лет колоний и лагерей будет
Posted by nguyenductam 5 Apr 2010 08:58
thank you.
Re: <TOP SECRET> 15 лет колоний и лагерей будет
Posted by Maqsud Erjonov 1 Dec 2010 11:13
thanks