http://poj.org/problem?id=2992

#include<set>      
#include<map>         
#include<stack>                
#include<queue>                
#include<vector>        
#include<string>     
#include<time.h>    
#include<math.h>                
#include<stdio.h>                
#include<iostream>                
#include<string.h>                
#include<stdlib.h>        
#include<algorithm>       
#include<functional>        
using namespace std;                
#define ll long long          
#define inf 1000000000           
#define mod 1000000007                
#define maxn  50500    
#define lowbit(x) (x&-x)                
#define eps 1e-9  
ll a[505]={1,1},b[500];
ll dp[450][450],cnt;
void init()
{
	ll i,j;
	for(i=2;i<=432;i++)
	{
		if(a[i])
			continue;
		b[++cnt]=i;
		for(j=i*i;j<=432;j+=i)
			a[j]=1;
	}
	for(i=2;i<=432;i++)
	{
		for(j=1;b[j]<=i && j<=cnt;j++)
		{
			ll tmp=i,res=0;
			while(tmp)
				tmp/=b[j],res+=tmp;
			dp[i][b[j]]=res;
		}
	}
}
int main(void)
{
	init();
	ll i,x,y;
	while(scanf("%lld%lld",&x,&y)!=EOF)
	{
		ll ans=1;
		for(i=1;b[i]<=x && i<=cnt;i++)
		{
			ll tmp=dp[x][b[i]]-dp[y][b[i]]-dp[x-y][b[i]];
			ans=ans*(tmp+1);
		}
		printf("%lld\n",ans);
	}
	return 0;
}